configurable stale time for profile queries
parent
65e349ee96
commit
a8d267e972
|
@ -27,16 +27,19 @@ import {queryClient} from '#/lib/react-query'
|
||||||
export const RQKEY = (did: string) => ['profile', did]
|
export const RQKEY = (did: string) => ['profile', did]
|
||||||
export const profilesQueryKey = (handles: string[]) => ['profiles', handles]
|
export const profilesQueryKey = (handles: string[]) => ['profiles', handles]
|
||||||
|
|
||||||
export function useProfileQuery({did}: {did: string | undefined}) {
|
export function useProfileQuery({
|
||||||
const {currentAccount} = useSession()
|
did,
|
||||||
const isCurrentAccount = did === currentAccount?.did
|
dontInvalidate,
|
||||||
|
}: {
|
||||||
|
did: string | undefined
|
||||||
|
dontInvalidate?: boolean
|
||||||
|
}) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
// WARNING
|
// WARNING
|
||||||
// this staleTime is load-bearing
|
// this staleTime is load-bearing
|
||||||
// if you remove it, the UI infinite-loops
|
// if you remove it, the UI infinite-loops
|
||||||
// -prf
|
// -prf
|
||||||
staleTime: isCurrentAccount ? STALE.SECONDS.THIRTY : STALE.MINUTES.FIVE,
|
staleTime: dontInvalidate ? STALE.INFINITY : STALE.SECONDS.FIFTEEN,
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
queryKey: RQKEY(did || ''),
|
queryKey: RQKEY(did || ''),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
|
Loading…
Reference in New Issue