|
1 | 1 | import type { AnyDocumentId, DocHandle, Repo } from '@automerge/automerge-repo'; |
2 | 2 | import { type Store, createStore } from '@xstate/store'; |
3 | 3 | import type { PrivateAppIdentity } from './connect/types.js'; |
| 4 | +import type { DocumentContent } from './entity/types.js'; |
4 | 5 | import { mergeMessages } from './inboxes/merge-messages.js'; |
5 | 6 | import type { InboxSenderAuthPolicy } from './inboxes/types.js'; |
6 | 7 | import type { Invitation, Updates } from './messages/index.js'; |
@@ -47,7 +48,7 @@ export type SpaceStorageEntry = { |
47 | 48 | events: SpaceEvent[]; |
48 | 49 | state: SpaceState | undefined; |
49 | 50 | keys: { id: string; key: string }[]; |
50 | | - automergeDocHandle: DocHandle<unknown> | undefined; |
| 51 | + automergeDocHandle: DocHandle<DocumentContent>; |
51 | 52 | inboxes: SpaceInboxStorageEntry[]; |
52 | 53 | }; |
53 | 54 |
|
@@ -194,7 +195,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create |
194 | 195 | for (const space of event.spaces) { |
195 | 196 | const existingSpace = context.spaces.find((s) => s.id === space.id); |
196 | 197 | const lastUpdateClock = context.lastUpdateClock[space.id] ?? -1; |
197 | | - const result = context.repo.findWithProgress(idToAutomergeId(space.id) as AnyDocumentId); |
| 198 | + const result = context.repo.findWithProgress<DocumentContent>(idToAutomergeId(space.id) as AnyDocumentId); |
198 | 199 |
|
199 | 200 | // set it to ready to interact with the document |
200 | 201 | result.handle.doneLoading(); |
@@ -245,8 +246,6 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create |
245 | 246 | } |
246 | 247 | } |
247 | 248 |
|
248 | | - console.log('storecontext', storeContext); |
249 | | - |
250 | 249 | return storeContext; |
251 | 250 | }, |
252 | 251 | applyEvent: (context, event: { spaceId: string; event: SpaceEvent; state: SpaceState }) => { |
@@ -439,7 +438,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create |
439 | 438 | ) => { |
440 | 439 | const existingSpace = context.spaces.find((s) => s.id === event.spaceId); |
441 | 440 | if (!existingSpace && context.repo) { |
442 | | - const result = context.repo.findWithProgress(idToAutomergeId(event.spaceId) as AnyDocumentId); |
| 441 | + const result = context.repo.findWithProgress<DocumentContent>(idToAutomergeId(event.spaceId) as AnyDocumentId); |
443 | 442 | // set it to ready to interact with the document |
444 | 443 | result.handle.doneLoading(); |
445 | 444 |
|
|
0 commit comments