Skip to content

Commit e1ac22a

Browse files
committed
invoke list spaces when using useSpaces for private case
1 parent c65d9d4 commit e1ac22a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

apps/events/src/routes/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function Index() {
1919
const accountInboxes = useSelector(store, (state) => state.context.accountInboxes);
2020
const {
2121
createSpace,
22-
listSpaces,
2322
listInvitations,
2423
invitations,
2524
acceptInvitation,
@@ -30,11 +29,10 @@ function Index() {
3029

3130
useEffect(() => {
3231
if (!isConnecting) {
33-
listSpaces();
3432
listInvitations();
3533
getOwnAccountInboxes();
3634
}
37-
}, [isConnecting, listSpaces, listInvitations, getOwnAccountInboxes]);
35+
}, [isConnecting, listInvitations, getOwnAccountInboxes]);
3836

3937
if (isConnecting) {
4038
return <div className="flex justify-center items-center h-screen">Loading …</div>;

packages/hypergraph-react/src/hooks/use-spaces.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { store } from '@graphprotocol/hypergraph';
22
import { useQuery } from '@tanstack/react-query';
33
import { useSelector } from '@xstate/store/react';
44
import { gql, request } from 'graphql-request';
5+
import { useEffect } from 'react';
6+
import { useHypergraphApp } from '../HypergraphAppContext.js';
57
import { GEO_API_TESTNET_ENDPOINT } from '../internal/constants.js';
68

79
const publicSpacesQueryDocument = gql`
@@ -47,6 +49,14 @@ export const useSpaces = (params: { mode: 'public' | 'private' }) => {
4749
enabled: params.mode === 'public' && !!accountAddress,
4850
});
4951

52+
const { isConnecting, listSpaces } = useHypergraphApp();
53+
54+
useEffect(() => {
55+
if (params.mode === 'private' && !isConnecting) {
56+
listSpaces();
57+
}
58+
}, [params.mode, listSpaces, isConnecting]);
59+
5060
const spaces = useSelector(store, (state) => state.context.spaces);
5161
const spacesLoadingIsPending = useSelector(store, (state) => state.context.spacesLoadingIsPending);
5262

0 commit comments

Comments
 (0)