Skip to content

Commit 4a3fcd3

Browse files
authored
feat(createSpace): return the created space id (#146)
1 parent 9e88aba commit 4a3fcd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type HypergraphAppCtx = {
2929
setIdentityAndSessionToken(account: Identity.Identity & { sessionToken: string }): void;
3030
// app related
3131
invitations: Array<Messages.Invitation>;
32-
createSpace(): Promise<unknown>;
32+
createSpace(): Promise<string>;
3333
listSpaces(): void;
3434
listInvitations(): void;
3535
acceptInvitation(params: Readonly<{ invitation: Messages.Invitation }>): Promise<unknown>;
@@ -511,7 +511,7 @@ export function HypergraphAppProvider({
511511
};
512512
}, [websocketConnection, spaces, accountId, keys?.encryptionPrivateKey, keys?.signaturePrivateKey, syncServerUri]);
513513

514-
const createSpaceForContext = useCallback(async () => {
514+
const createSpaceForContext = useCallback<() => Promise<string>>(async () => {
515515
if (!accountId) {
516516
throw new Error('No account id found');
517517
}
@@ -550,6 +550,10 @@ export function HypergraphAppProvider({
550550
},
551551
} as const satisfies Messages.RequestCreateSpaceEvent;
552552
websocketConnection?.send(Messages.serialize(message));
553+
554+
// return the created space id
555+
// @todo return created Space with name, etc
556+
return spaceEvent.transaction.id;
553557
}, [
554558
accountId,
555559
keys?.encryptionPrivateKey,

0 commit comments

Comments
 (0)