mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refetch some data on an interval (#2114)

* Match refetch intervals to stale time

* Lower refetch interval for own-profile

authored by

Eric Bailey and committed by
GitHub
a924df4d 47771b90

+17 -4
+2 -1
src/state/queries/app-passwords.ts
··· 8 8 9 9 export function useAppPasswordsQuery() { 10 10 return useQuery({ 11 - staleTime: STALE.MINUTES.ONE, 11 + staleTime: STALE.MINUTES.FIVE, 12 + refetchInterval: STALE.MINUTES.ONE, 12 13 queryKey: RQKEY(), 13 14 queryFn: async () => { 14 15 const res = await getAgent().com.atproto.server.listAppPasswords({})
+4
src/state/queries/index.ts
··· 5 5 }) 6 6 7 7 export const STALE = { 8 + SECONDS: { 9 + FIFTEEN: 1e3 * 15, 10 + THIRTY: 1e3 * 30, 11 + }, 8 12 MINUTES: { 9 13 ONE: 1e3 * 60, 10 14 FIVE: 1e3 * 60 * 5,
+2 -1
src/state/queries/invites.ts
··· 15 15 > 16 16 export function useInviteCodesQuery() { 17 17 return useQuery({ 18 - staleTime: STALE.HOURS.ONE, 18 + staleTime: STALE.MINUTES.FIVE, 19 + refetchInterval: STALE.MINUTES.FIVE, 19 20 queryKey: ['inviteCodes'], 20 21 queryFn: async () => { 21 22 const res = await getAgent()
+2 -1
src/state/queries/preferences/index.ts
··· 28 28 29 29 export function usePreferencesQuery() { 30 30 return useQuery({ 31 - staleTime: STALE.MINUTES.ONE, 31 + staleTime: STALE.SECONDS.FIFTEEN, 32 32 structuralSharing: true, 33 + refetchInterval: STALE.SECONDS.FIFTEEN, 33 34 queryKey: preferencesQueryKey, 34 35 queryFn: async () => { 35 36 const agent = getAgent()
+7 -1
src/state/queries/profile.ts
··· 26 26 export const RQKEY = (did: string) => ['profile', did] 27 27 28 28 export function useProfileQuery({did}: {did: string | undefined}) { 29 + const {currentAccount} = useSession() 30 + const isCurrentAccount = did === currentAccount?.did 31 + 29 32 return useQuery({ 30 33 // WARNING 31 34 // this staleTime is load-bearing 32 35 // if you remove it, the UI infinite-loops 33 36 // -prf 34 - staleTime: STALE.MINUTES.FIVE, 37 + staleTime: isCurrentAccount ? STALE.SECONDS.THIRTY : STALE.MINUTES.FIVE, 38 + refetchInterval: isCurrentAccount 39 + ? STALE.SECONDS.THIRTY 40 + : STALE.MINUTES.FIVE, 35 41 queryKey: RQKEY(did || ''), 36 42 queryFn: async () => { 37 43 const res = await getAgent().getProfile({actor: did || ''})