about summary refs log tree commit diff
path: root/src/state/queries/profile.ts
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2023-11-30 17:11:51 +0000
committerSamuel Newman <mozzius@protonmail.com>2023-11-30 17:11:51 +0000
commitb164f151cc352c62212a815e77dbdd23be530e7f (patch)
tree4df0df19dcd07afb1909171429ddc3ebcbfa42c5 /src/state/queries/profile.ts
parentee5d7a63ce08f2b395c71fb35dbdb0d9bb0f1dee (diff)
parentfcd22d4ccb0718db1c9b64fccd90a8bfe3e885d4 (diff)
downloadvoidsky-b164f151cc352c62212a815e77dbdd23be530e7f.tar.zst
Merge remote-tracking branch 'upstream/main' into invite-code-warning
Diffstat (limited to 'src/state/queries/profile.ts')
-rw-r--r--src/state/queries/profile.ts10
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}),
   )
 }