Retrait de expo-background-fetch, inutilisé
This commit is contained in:
parent
25ca687448
commit
3648454da4
@ -40,7 +40,6 @@
|
||||
"favicon": "./assets/images/favicon.png"
|
||||
},
|
||||
"plugins": [
|
||||
"expo-background-fetch",
|
||||
[
|
||||
"expo-location",
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -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) }
|
||||
})
|
||||
|
||||
|
13
client/package-lock.json
generated
13
client/package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
}, [])
|
Loading…
Reference in New Issue
Block a user