From 30a687018f49aae4dd2ed4274048378b01da477c Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Fri, 13 Dec 2024 00:32:52 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20envoi=20derni=C3=A8re=20position?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/FreeChaseBanner.tsx | 2 +- client/components/GeolocationProvider.tsx | 4 ++-- client/utils/features/location/locationSlice.ts | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/components/FreeChaseBanner.tsx b/client/components/FreeChaseBanner.tsx index a0ff488..9cbc5b8 100644 --- a/client/components/FreeChaseBanner.tsx +++ b/client/components/FreeChaseBanner.tsx @@ -40,7 +40,7 @@ export default function FreeChaseBanner() { icon={({ size }) => } style={{ backgroundColor: MD3Colors.secondary40 }}> - Vous pourrez vous mettre en chasse à {chaseFreePretty}. + Vous pourrez commencer la poursuite à {chaseFreePretty}. Temps restant : {prettyRemainingTime} diff --git a/client/components/GeolocationProvider.tsx b/client/components/GeolocationProvider.tsx index a7f4363..e62dfb4 100644 --- a/client/components/GeolocationProvider.tsx +++ b/client/components/GeolocationProvider.tsx @@ -13,8 +13,8 @@ export default function GeolocationProvider({ children }: { children: ReactNode const unqueueLocation = useUnqueueLocation() const geolocationMutation = useGeolocationMutation({ auth, - onPostSuccess: ({ data, variables: location }) => { - unqueueLocation(location) + onPostSuccess: (data) => { + unqueueLocation(data) geolocationMutation.reset() }, onError: ({ response, error }) => { console.error(response, error) } diff --git a/client/utils/features/location/locationSlice.ts b/client/utils/features/location/locationSlice.ts index c7c808d..c57ec66 100644 --- a/client/utils/features/location/locationSlice.ts +++ b/client/utils/features/location/locationSlice.ts @@ -27,7 +27,11 @@ export const locationSlice = createSlice({ } }, unqueueLocation: (state, action: PayloadAction) => { - state.queuedLocations.pop() + const sentLoc = action.payload + state.queuedLocations = state.queuedLocations + .filter(loc => new Date(loc.timestamp).getTime() !== sentLoc.timestamp + || loc.coords.latitude !== sentLoc.coords.latitude + || loc.coords.longitude !== sentLoc.coords.latitude) }, }, })