From b6be27b22839bb433944fd471976570b21e17510 Mon Sep 17 00:00:00 2001 From: Chris Whited Date: Wed, 5 Feb 2025 11:34:58 -1000 Subject: [PATCH] feat(createSpace): return the created space id --- packages/hypergraph-react/src/HypergraphAppContext.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/hypergraph-react/src/HypergraphAppContext.tsx b/packages/hypergraph-react/src/HypergraphAppContext.tsx index 6892fd10..26691d13 100644 --- a/packages/hypergraph-react/src/HypergraphAppContext.tsx +++ b/packages/hypergraph-react/src/HypergraphAppContext.tsx @@ -29,7 +29,7 @@ export type HypergraphAppCtx = { setIdentityAndSessionToken(account: Identity.Identity & { sessionToken: string }): void; // app related invitations: Array; - createSpace(): Promise; + createSpace(): Promise; listSpaces(): void; listInvitations(): void; acceptInvitation(params: Readonly<{ invitation: Messages.Invitation }>): Promise; @@ -511,7 +511,7 @@ export function HypergraphAppProvider({ }; }, [websocketConnection, spaces, accountId, keys?.encryptionPrivateKey, keys?.signaturePrivateKey, syncServerUri]); - const createSpaceForContext = useCallback(async () => { + const createSpaceForContext = useCallback<() => Promise>(async () => { if (!accountId) { throw new Error('No account id found'); } @@ -550,6 +550,10 @@ export function HypergraphAppProvider({ }, } as const satisfies Messages.RequestCreateSpaceEvent; websocketConnection?.send(Messages.serialize(message)); + + // return the created space id + // @todo return created Space with name, etc + return spaceEvent.transaction.id; }, [ accountId, keys?.encryptionPrivateKey,