diff --git a/client/app.json b/client/app.json index a58b59c..fdcf9e5 100644 --- a/client/app.json +++ b/client/app.json @@ -40,7 +40,6 @@ "favicon": "./assets/images/favicon.png" }, "plugins": [ - "expo-background-fetch", [ "expo-location", { diff --git a/client/app/_layout.tsx b/client/app/_layout.tsx index af7a3f2..9ee573a 100644 --- a/client/app/_layout.tsx +++ b/client/app/_layout.tsx @@ -11,7 +11,6 @@ import { useReactNavigationDevTools } from '@dev-plugins/react-navigation' import { useReactQueryDevTools } from '@dev-plugins/react-query' import { useColorScheme } from '@/hooks/useColorScheme' import store from '@/utils/store' -import { useStartBackgroundFetchServiceEffect } from '@/utils/background' import LoginProvider from '@/components/LoginProvider' import GeolocationProvider from '@/components/GeolocationProvider' import GameProvider from '@/components/GameProvider' @@ -27,7 +26,6 @@ const queryClient = new QueryClient({ }) export default function RootLayout() { - useStartBackgroundFetchServiceEffect() const colorScheme = useColorScheme() const navigationRef = useNavigationContainerRef() diff --git a/client/components/GeolocationProvider.tsx b/client/components/GeolocationProvider.tsx index 627dc75..87b8104 100644 --- a/client/components/GeolocationProvider.tsx +++ b/client/components/GeolocationProvider.tsx @@ -16,10 +16,7 @@ export default function GeolocationProvider({ children }: { children: ReactNode const setLastPlayerLocations = useSetLastPlayerLocations() const geolocationMutation = useGeolocationMutation({ auth, - onPostSuccess: (data) => { - unqueueLocation(data) - geolocationMutation.reset() - }, + onPostSuccess: (data) => unqueueLocation(data), onError: ({ response, error }) => { console.error(response, error) } }) diff --git a/client/package-lock.json b/client/package-lock.json index 17a8047..06830fa 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -22,7 +22,6 @@ "@tanstack/react-query-persist-client": "^5.62.7", "@turf/circle": "^7.1.0", "expo": "~52.0.11", - "expo-background-fetch": "~13.0.3", "expo-blur": "~14.0.1", "expo-constants": "~17.0.3", "expo-dev-client": "~5.0.4", @@ -7765,18 +7764,6 @@ "react-native": "*" } }, - "node_modules/expo-background-fetch": { - "version": "13.0.3", - "resolved": "https://registry.npmjs.org/expo-background-fetch/-/expo-background-fetch-13.0.3.tgz", - "integrity": "sha512-wayjvMima858mvEqsXo6camcoeBLusVJnvMPdG0GKi2d9hKuQXCNP90sShDpgXOEIVzjN0UzZ8PqULgQWbqdAg==", - "license": "MIT", - "dependencies": { - "expo-task-manager": "~12.0.0" - }, - "peerDependencies": { - "expo": "*" - } - }, "node_modules/expo-blur": { "version": "14.0.1", "resolved": "https://registry.npmjs.org/expo-blur/-/expo-blur-14.0.1.tgz", diff --git a/client/package.json b/client/package.json index f0ddffa..b11d0dd 100644 --- a/client/package.json +++ b/client/package.json @@ -28,7 +28,6 @@ "@tanstack/react-query-persist-client": "^5.62.7", "@turf/circle": "^7.1.0", "expo": "~52.0.11", - "expo-background-fetch": "~13.0.3", "expo-blur": "~14.0.1", "expo-constants": "~17.0.3", "expo-dev-client": "~5.0.4", diff --git a/client/utils/background.ts b/client/utils/background.ts deleted file mode 100644 index b1a2bb9..0000000 --- a/client/utils/background.ts +++ /dev/null @@ -1,40 +0,0 @@ -import * as BackgroundFetch from 'expo-background-fetch' -import * as TaskManager from 'expo-task-manager' -import { Platform } from 'react-native' -import { useEffect } from 'react' - -const BACKGROUND_FETCH_TASK = "background-fetch" -const BACKGROUND_FETCH_INTERVAL = 60000 - -async function backgroundUpdate() { - const now = Date.now() - console.log(`Got background fetch call at date: ${new Date(now).toISOString()}`) - // Be sure to return the successful result type! - return BackgroundFetch.BackgroundFetchResult.NewData -} - -TaskManager.defineTask(BACKGROUND_FETCH_TASK, backgroundUpdate) - -export async function startBackgroundFetchService(): Promise void)> { - if (Platform.OS === "web") { - const interval = setInterval(backgroundUpdate, BACKGROUND_FETCH_INTERVAL) - return () => clearInterval(interval) - } - - if (await TaskManager.isTaskRegisteredAsync(BACKGROUND_FETCH_TASK)) - return async () => await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK) - - await BackgroundFetch.registerTaskAsync(BACKGROUND_FETCH_TASK, { - minimumInterval: BACKGROUND_FETCH_INTERVAL, - stopOnTerminate: false, - startOnBoot: true, - }) - - return async () => await BackgroundFetch.unregisterTaskAsync(BACKGROUND_FETCH_TASK) -} - -export const useStartBackgroundFetchServiceEffect = () => useEffect(() => { - let cleanup: void | (() => void) = () => {} - startBackgroundFetchService().then(result => cleanup = result) - return cleanup -}, [])