Retrait de expo-background-fetch, inutilisé

This commit is contained in:
Emmy D'Anello 2024-12-14 17:41:59 +01:00
parent 25ca687448
commit 3648454da4
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
6 changed files with 1 additions and 61 deletions

View File

@ -40,7 +40,6 @@
"favicon": "./assets/images/favicon.png" "favicon": "./assets/images/favicon.png"
}, },
"plugins": [ "plugins": [
"expo-background-fetch",
[ [
"expo-location", "expo-location",
{ {

View File

@ -11,7 +11,6 @@ import { useReactNavigationDevTools } from '@dev-plugins/react-navigation'
import { useReactQueryDevTools } from '@dev-plugins/react-query' import { useReactQueryDevTools } from '@dev-plugins/react-query'
import { useColorScheme } from '@/hooks/useColorScheme' import { useColorScheme } from '@/hooks/useColorScheme'
import store from '@/utils/store' import store from '@/utils/store'
import { useStartBackgroundFetchServiceEffect } from '@/utils/background'
import LoginProvider from '@/components/LoginProvider' import LoginProvider from '@/components/LoginProvider'
import GeolocationProvider from '@/components/GeolocationProvider' import GeolocationProvider from '@/components/GeolocationProvider'
import GameProvider from '@/components/GameProvider' import GameProvider from '@/components/GameProvider'
@ -27,7 +26,6 @@ const queryClient = new QueryClient({
}) })
export default function RootLayout() { export default function RootLayout() {
useStartBackgroundFetchServiceEffect()
const colorScheme = useColorScheme() const colorScheme = useColorScheme()
const navigationRef = useNavigationContainerRef() const navigationRef = useNavigationContainerRef()

View File

@ -16,10 +16,7 @@ export default function GeolocationProvider({ children }: { children: ReactNode
const setLastPlayerLocations = useSetLastPlayerLocations() const setLastPlayerLocations = useSetLastPlayerLocations()
const geolocationMutation = useGeolocationMutation({ const geolocationMutation = useGeolocationMutation({
auth, auth,
onPostSuccess: (data) => { onPostSuccess: (data) => unqueueLocation(data),
unqueueLocation(data)
geolocationMutation.reset()
},
onError: ({ response, error }) => { console.error(response, error) } onError: ({ response, error }) => { console.error(response, error) }
}) })

View File

@ -22,7 +22,6 @@
"@tanstack/react-query-persist-client": "^5.62.7", "@tanstack/react-query-persist-client": "^5.62.7",
"@turf/circle": "^7.1.0", "@turf/circle": "^7.1.0",
"expo": "~52.0.11", "expo": "~52.0.11",
"expo-background-fetch": "~13.0.3",
"expo-blur": "~14.0.1", "expo-blur": "~14.0.1",
"expo-constants": "~17.0.3", "expo-constants": "~17.0.3",
"expo-dev-client": "~5.0.4", "expo-dev-client": "~5.0.4",
@ -7765,18 +7764,6 @@
"react-native": "*" "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": { "node_modules/expo-blur": {
"version": "14.0.1", "version": "14.0.1",
"resolved": "https://registry.npmjs.org/expo-blur/-/expo-blur-14.0.1.tgz", "resolved": "https://registry.npmjs.org/expo-blur/-/expo-blur-14.0.1.tgz",

View File

@ -28,7 +28,6 @@
"@tanstack/react-query-persist-client": "^5.62.7", "@tanstack/react-query-persist-client": "^5.62.7",
"@turf/circle": "^7.1.0", "@turf/circle": "^7.1.0",
"expo": "~52.0.11", "expo": "~52.0.11",
"expo-background-fetch": "~13.0.3",
"expo-blur": "~14.0.1", "expo-blur": "~14.0.1",
"expo-constants": "~17.0.3", "expo-constants": "~17.0.3",
"expo-dev-client": "~5.0.4", "expo-dev-client": "~5.0.4",

View File

@ -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 | (() => 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
}, [])