diff options
author | dan <dan.abramov@gmail.com> | 2023-11-30 21:35:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 13:35:58 -0800 |
commit | 46b63accb8e73997f2a1bee24cfda220d29e048b (patch) | |
tree | 748de65b464e98d8241cc6fd8d11a9c17d9ec05c /src/state/queries/profile.ts | |
parent | 143fc80951d3a0620c0a5e55f46229f2fc743758 (diff) | |
download | voidsky-46b63accb8e73997f2a1bee24cfda220d29e048b.tar.zst |
Rewrite the shadow logic to look inside the cache (#2045)
* Reset * Associate shadows with the cache * Use colocated helpers * Fix types * Reorder for clarity * More types * Copy paste logic for profile * Hook up profile query * Hook up suggested follows * Hook up other profile things * Fix shape * Pass setShadow into the effect deps * Include reply posts in the shadow cache search --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/state/queries/profile.ts')
-rw-r--r-- | src/state/queries/profile.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index 62e8f39c0..9435d7ad5 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -5,7 +5,12 @@ import { AppBskyActorProfile, AppBskyActorGetProfile, } from '@atproto/api' -import {useQuery, useQueryClient, useMutation} from '@tanstack/react-query' +import { + useQuery, + useQueryClient, + useMutation, + QueryClient, +} from '@tanstack/react-query' import {Image as RNImage} from 'react-native-image-crop-picker' import {useSession, getAgent} from '../session' import {updateProfileShadow} from '../cache/profile-shadow' @@ -477,3 +482,21 @@ async function whenAppViewReady( () => getAgent().app.bsky.actor.getProfile({actor}), ) } + +export function* findAllProfilesInQueryData( + queryClient: QueryClient, + did: string, +): Generator<AppBskyActorDefs.ProfileViewDetailed, void> { + const queryDatas = + queryClient.getQueriesData<AppBskyActorDefs.ProfileViewDetailed>({ + queryKey: ['profile'], + }) + for (const [_queryKey, queryData] of queryDatas) { + if (!queryData) { + continue + } + if (queryData.did === did) { + yield queryData + } + } +} |