Skip to content

Commit f5ace00

Browse files
committed
Cache updates
1 parent 195b01d commit f5ace00

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/hooks/queries/useCompetition.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const useCompetition = (competitionId?: string) => {
1111
return useQuery<ApiCompetition>({
1212
...competitionQuery(competitionId ?? ''),
1313
networkMode: 'offlineFirst',
14-
gcTime: 1000 * 60 * 5,
14+
staleTime: 60 * 60 * 1000, // 1 hour
15+
gcTime: 24 * 60 * 60 * 1000, // 24 hours
1516
enabled: !!competitionId,
1617
});
1718
};

src/hooks/queries/useWcif.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ import { queryClient } from '@/providers/QueryProvider';
66
export const useWcif = (competitionId?: string) =>
77
useQuery<Competition>({
88
queryKey: ['wcif', competitionId],
9-
queryFn: () => fetchWcif(competitionId!),
10-
initialData: () => {
9+
queryFn: () => {
10+
return fetchWcif(competitionId!);
11+
},
12+
staleTime: 5 * 60 * 1000, // 5 minutes
13+
gcTime: 24 * 60 * 60 * 1000, // 24 hours
14+
refetchOnMount: false,
15+
refetchOnWindowFocus: false,
16+
refetchInterval: 5 * 60 * 1000, // 5 minutes
17+
refetchOnReconnect: true,
18+
placeholderData: () => {
1119
const upcomingComps =
1220
queryClient
1321
.getQueryData<InfiniteData<CondensedApiCompetiton[]>>(['upcomingCompetitions'])

0 commit comments

Comments
 (0)