diff options
author | Hailey <me@haileyok.com> | 2024-01-29 18:37:41 -0800 |
---|---|---|
committer | Hailey <me@haileyok.com> | 2024-01-29 18:37:41 -0800 |
commit | a8d267e9729d791964ed9c1f3c3555f535ba2918 (patch) | |
tree | e73360be65c657bf369838d397c7c585d1b0f35b /src | |
parent | 65e349ee96d74e1792da7a336506f72278eed231 (diff) | |
download | voidsky-a8d267e9729d791964ed9c1f3c3555f535ba2918.tar.zst |
configurable stale time for profile queries
Diffstat (limited to 'src')
-rw-r--r-- | src/state/queries/profile.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index cdfbf2007..7bdef68ae 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -27,16 +27,19 @@ import {queryClient} from '#/lib/react-query' export const RQKEY = (did: string) => ['profile', did] export const profilesQueryKey = (handles: string[]) => ['profiles', handles] -export function useProfileQuery({did}: {did: string | undefined}) { - const {currentAccount} = useSession() - const isCurrentAccount = did === currentAccount?.did - +export function useProfileQuery({ + did, + dontInvalidate, +}: { + did: string | undefined + dontInvalidate?: boolean +}) { return useQuery({ // WARNING // this staleTime is load-bearing // if you remove it, the UI infinite-loops // -prf - staleTime: isCurrentAccount ? STALE.SECONDS.THIRTY : STALE.MINUTES.FIVE, + staleTime: dontInvalidate ? STALE.INFINITY : STALE.SECONDS.FIFTEEN, refetchOnWindowFocus: true, queryKey: RQKEY(did || ''), queryFn: async () => { |