Stabilité téléchargement des données

This commit is contained in:
Emmy D'Anello 2024-12-14 00:53:22 +01:00
parent 3d50cee9a9
commit 57676abb02
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 4 additions and 1 deletions

View File

@ -57,6 +57,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
headers: { "Authorization": `Bearer ${auth.token}` }} headers: { "Authorization": `Bearer ${auth.token}` }}
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth) && !!game.playerId, enabled: isAuthValid(auth) && !!game.playerId,
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
refetchInterval: 5000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
@ -70,6 +71,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
headers: { "Authorization": `Bearer ${auth.token}` }} headers: { "Authorization": `Bearer ${auth.token}` }}
).then(resp => resp.json()), ).then(resp => resp.json()),
enabled: isAuthValid(auth), enabled: isAuthValid(auth),
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
refetchInterval: 5000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {

View File

@ -39,13 +39,14 @@ export default function GeolocationProvider({ children }: { children: ReactNode
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}).then(resp => resp.json()), }).then(resp => resp.json()),
initialData: [],
enabled: isAuthValid(auth), enabled: isAuthValid(auth),
refetchInterval: 5000, refetchInterval: 5000,
}) })
useEffect(() => { useEffect(() => {
if (lastLocationsQuery.isSuccess && lastLocationsQuery.data) if (lastLocationsQuery.isSuccess && lastLocationsQuery.data)
setLastPlayerLocations(lastLocationsQuery.data) setLastPlayerLocations(lastLocationsQuery.data)
}, [lastLocationsQuery.status, lastLocationsQuery.dataUpdatedAt, auth]) }, [lastLocationsQuery.status, lastLocationsQuery.dataUpdatedAt])
return <> return <>
{children} {children}