diff options
Diffstat (limited to 'src/state/queries/profile.ts')
-rw-r--r-- | src/state/queries/profile.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index e27bac9a6..62e8f39c0 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -4,7 +4,6 @@ import { AppBskyActorDefs, AppBskyActorProfile, AppBskyActorGetProfile, - BskyAgent, } from '@atproto/api' import {useQuery, useQueryClient, useMutation} from '@tanstack/react-query' import {Image as RNImage} from 'react-native-image-crop-picker' @@ -22,6 +21,10 @@ export const RQKEY = (did: string) => ['profile', did] export function useProfileQuery({did}: {did: string | undefined}) { return useQuery({ + // WARNING + // this staleTime is load-bearing + // if you remove it, the UI infinite-loops + // -prf staleTime: STALE.MINUTES.FIVE, queryKey: RQKEY(did || ''), queryFn: async () => { @@ -68,7 +71,7 @@ export function useProfileUpdateMutation() { } return existing }) - await whenAppViewReady(getAgent(), profile.did, res => { + await whenAppViewReady(profile.did, res => { if (typeof newUserAvatar !== 'undefined') { if (newUserAvatar === null && res.data.avatar) { // url hasnt cleared yet @@ -464,7 +467,6 @@ function useProfileUnblockMutation() { } async function whenAppViewReady( - agent: BskyAgent, actor: string, fn: (res: AppBskyActorGetProfile.Response) => boolean, ) { @@ -472,6 +474,6 @@ async function whenAppViewReady( 5, // 5 tries 1e3, // 1s delay between tries fn, - () => agent.app.bsky.actor.getProfile({actor}), + () => getAgent().app.bsky.actor.getProfile({actor}), ) } |