Skip to content

Commit

Permalink
tweak rqkey and cache search for useAllListMembersQuery (#4971)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok authored Aug 22, 2024
1 parent d5c78b9 commit 85d70fe
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/state/queries/list-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const PAGE_SIZE = 30
type RQPageParam = string | undefined

const RQKEY_ROOT = 'list-members'
const RQKEY_ROOT_ALL = 'list-members-all'
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
export const RQKEY_ALL = (uri: string) => [RQKEY_ROOT, uri, 'all']
export const RQKEY_ALL = (uri: string) => [RQKEY_ROOT_ALL, uri]

export function useListMembersQuery(uri?: string, limit: number = PAGE_SIZE) {
const agent = useAgent()
Expand Down Expand Up @@ -118,4 +119,20 @@ export function* findAllProfilesInQueryData(
}
}
}

const allQueryData = queryClient.getQueriesData<
AppBskyGraphDefs.ListItemView[]
>({
queryKey: [RQKEY_ROOT_ALL],
})
for (const [_queryKey, queryData] of allQueryData) {
if (!queryData) {
continue
}
for (const item of queryData) {
if (item.subject.did === did) {
yield item.subject
}
}
}
}

0 comments on commit 85d70fe

Please sign in to comment.