about summary refs log tree commit diff
path: root/src/state/queries/profile.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2023-12-06 14:31:54 -0600
committerGitHub <noreply@github.com>2023-12-06 12:31:54 -0800
commita924df4dcd87b9963699643d04475dc89c926633 (patch)
treef921f6dd4a0273cebdeffcd5b2351640f532b01c /src/state/queries/profile.ts
parent47771b906658d56106c7e78efcd46524eebfb358 (diff)
downloadvoidsky-a924df4dcd87b9963699643d04475dc89c926633.tar.zst
Refetch some data on an interval (#2114)
* Match refetch intervals to stale time

* Lower refetch interval for own-profile
Diffstat (limited to 'src/state/queries/profile.ts')
-rw-r--r--src/state/queries/profile.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index 267cf2c5b..21e519a0f 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -26,12 +26,18 @@ import {track} from '#/lib/analytics/analytics'
 export const RQKEY = (did: string) => ['profile', did]
 
 export function useProfileQuery({did}: {did: string | undefined}) {
+  const {currentAccount} = useSession()
+  const isCurrentAccount = did === currentAccount?.did
+
   return useQuery({
     // WARNING
     // this staleTime is load-bearing
     // if you remove it, the UI infinite-loops
     // -prf
-    staleTime: STALE.MINUTES.FIVE,
+    staleTime: isCurrentAccount ? STALE.SECONDS.THIRTY : STALE.MINUTES.FIVE,
+    refetchInterval: isCurrentAccount
+      ? STALE.SECONDS.THIRTY
+      : STALE.MINUTES.FIVE,
     queryKey: RQKEY(did || ''),
     queryFn: async () => {
       const res = await getAgent().getProfile({actor: did || ''})