diff --git a/src/rtk/features/spaces/spacesSlice.ts b/src/rtk/features/spaces/spacesSlice.ts index add4711f9..5b87fcf2c 100644 --- a/src/rtk/features/spaces/spacesSlice.ts +++ b/src/rtk/features/spaces/spacesSlice.ts @@ -143,9 +143,20 @@ const getSpaces = createFetchDataFn([])({ } return entities }, - squid: async ({ ids }: { ids: string[] }, client) => { - const spaces = await getSpacesData(client, { where: { id_in: ids } }) - return spaces.map(space => ({ ...space, isOverview: true })) + squid: async ({ api, ids }: { api: SubsocialApi; ids: string[] }, client) => { + // need to fetch from chain to get correct permissions, while fetch from squid to prefetch the content + const [spaces, spacesFromChain] = await Promise.all([ + getSpacesData(client, { where: { id_in: ids } }), + api.findSpaceStructs(ids), + ] as const) + const spacesFromChainMap = new Map() + spacesFromChain.forEach(space => spacesFromChainMap.set(space.id, space)) + + return spaces.map(space => ({ + ...space, + ...spacesFromChainMap.get(space.id), + isOverview: false, + })) }, }) export const fetchSpaces = createAsyncThunk( @@ -201,7 +212,7 @@ export const fetchSpaces = createAsyncThunk