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>
This commit is contained in:
parent
143fc80951
commit
46b63accb8
14 changed files with 462 additions and 172 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue