From 409e13277eab6d82d0dde34a14d0e571d3fa77af Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Tue, 17 Dec 2024 01:12:54 +0100 Subject: [PATCH] =?UTF-8?q?Passage=20du=20d=C3=A9lai=20de=20mise=20=C3=A0?= =?UTF-8?q?=20jour=20des=20donn=C3=A9es=20depuis=20le=20serveur=20=C3=A0?= =?UTF-8?q?=2015=20secondes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/providers/GameProvider.tsx | 11 ++++++----- client/components/providers/GeolocationProvider.tsx | 3 ++- client/constants/Constants.ts | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/components/providers/GameProvider.tsx b/client/components/providers/GameProvider.tsx index 905fb15..f315b2e 100644 --- a/client/components/providers/GameProvider.tsx +++ b/client/components/providers/GameProvider.tsx @@ -1,3 +1,4 @@ +import { Constants } from '@/constants/Constants' import { useAuth } from '@/hooks/useAuth' import { useChallengeActions, useDownloadChallengeActions } from '@/hooks/useChallengeActions' import { useDownloadChallenges } from '@/hooks/useChallenges' @@ -31,7 +32,7 @@ export default function GameProvider({ children }: { children: ReactNode }) { headers: { "Authorization": `Bearer ${auth.token}` }} ).then(resp => resp.json()), enabled: isAuthValid(auth), - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (gameQuery.isSuccess && gameQuery.data) @@ -44,7 +45,7 @@ export default function GameProvider({ children }: { children: ReactNode }) { headers: { "Authorization": `Bearer ${auth.token}` }} ).then(resp => resp.json()), enabled: isAuthValid(auth) && !!game.playerId, - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (playerQuery.isSuccess && playerQuery.data) { @@ -60,7 +61,7 @@ export default function GameProvider({ children }: { children: ReactNode }) { ).then(resp => resp.json()), enabled: isAuthValid(auth) && !!game.playerId, initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } }, - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (trainsQuery.isSuccess && trainsQuery.data) @@ -74,7 +75,7 @@ export default function GameProvider({ children }: { children: ReactNode }) { ).then(resp => resp.json()), enabled: isAuthValid(auth), initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } }, - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (challengesQuery.isSuccess && challengesQuery.data) { @@ -91,7 +92,7 @@ export default function GameProvider({ children }: { children: ReactNode }) { headers: { "Authorization": `Bearer ${auth.token}` }} ).then(resp => resp.json()), enabled: isAuthValid(auth) && !!game.playerId, - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (moneyUpdatesQuery.isSuccess && moneyUpdatesQuery.data) diff --git a/client/components/providers/GeolocationProvider.tsx b/client/components/providers/GeolocationProvider.tsx index 7d2fd5e..9dfb1e5 100644 --- a/client/components/providers/GeolocationProvider.tsx +++ b/client/components/providers/GeolocationProvider.tsx @@ -8,6 +8,7 @@ import { useQuery } from '@tanstack/react-query' import { isAuthValid } from '@/utils/features/auth/authSlice' import { socket } from '@/utils/socket' import { PlayerLocation } from '@/utils/features/location/locationSlice' +import { Constants } from '@/constants/Constants' export default function GeolocationProvider({ children }: { children: ReactNode }) { useStartGeolocationServiceEffect() @@ -43,7 +44,7 @@ export default function GeolocationProvider({ children }: { children: ReactNode }).then(resp => resp.json()), initialData: [], enabled: isAuthValid(auth), - refetchInterval: 5000, + refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000, }) useEffect(() => { if (lastLocationsQuery.isSuccess && lastLocationsQuery.data) diff --git a/client/constants/Constants.ts b/client/constants/Constants.ts index 5e2e0de..1183c68 100644 --- a/client/constants/Constants.ts +++ b/client/constants/Constants.ts @@ -1,3 +1,4 @@ export const Constants = { - MIN_DELAY_LOCATION_SENT: 20 + MIN_DELAY_LOCATION_SENT: 20, + QUERY_REFETCH_INTERVAL: 15, }