diff --git a/client/components/GeolocationProvider.tsx b/client/components/GeolocationProvider.tsx index 04fc960..e27b680 100644 --- a/client/components/GeolocationProvider.tsx +++ b/client/components/GeolocationProvider.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useEffect } from 'react' +import { ReactNode, useEffect, useState } from 'react' import { useAuth } from '@/hooks/useAuth' import { useQueuedLocations, useSetLastPlayerLocations, useUnqueueLocation } from '@/hooks/useLocation' import { useGeolocationMutation } from '@/hooks/mutations/useGeolocationMutation' @@ -16,16 +16,16 @@ export default function GeolocationProvider({ children }: { children: ReactNode const setLastPlayerLocations = useSetLastPlayerLocations() const geolocationMutation = useGeolocationMutation({ auth, - onPostSuccess: (data) => unqueueLocation(data), - onError: ({ response, error }) => { console.error(response, error) } + onPostSuccess: (data, variables) => unqueueLocation(variables), + onError: ({ response, error }) => console.error(response, error), }) if (Platform.OS !== "web") { useEffect(() => { if (geolocationsQueue.length === 0 || geolocationMutation.isPending || !isAuthValid(auth)) return - const locToSend = geolocationsQueue[0] - geolocationMutation.mutate(locToSend) + const locToSend = geolocationsQueue[0] + geolocationMutation.mutate(locToSend) }, [auth, geolocationMutation.status, geolocationsQueue]) } diff --git a/client/utils/features/location/locationSlice.ts b/client/utils/features/location/locationSlice.ts index 65810c7..e863dfa 100644 --- a/client/utils/features/location/locationSlice.ts +++ b/client/utils/features/location/locationSlice.ts @@ -44,8 +44,8 @@ export const locationSlice = createSlice({ 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) + && loc.coords.latitude !== sentLoc.coords.latitude + && loc.coords.longitude !== sentLoc.coords.longitude) }, setLastPlayerLocations: (state, action: PayloadAction) => { state.lastPlayerLocations = action.payload