diff options
author | Hailey <me@haileyok.com> | 2024-08-22 09:32:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-22 09:32:49 -0700 |
commit | 85d70fe3efe67d8b94d752ef1408e2782d78146c (patch) | |
tree | 6951471d1cf52152b6ef4be065f0bccc0a3f4d8c | |
parent | d5c78b9183ac78620f59538fed61c8130ae1c47a (diff) | |
download | voidsky-85d70fe3efe67d8b94d752ef1408e2782d78146c.tar.zst |
tweak rqkey and cache search for useAllListMembersQuery (#4971)
-rw-r--r-- | src/state/queries/list-members.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/state/queries/list-members.ts b/src/state/queries/list-members.ts index b02cc9910..1aeb1bdd4 100644 --- a/src/state/queries/list-members.ts +++ b/src/state/queries/list-members.ts @@ -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() @@ -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 + } + } + } } |