This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useMemo, useEffect } from "react";
|
|||||||
import { StatusBar } from "expo-status-bar";
|
import { StatusBar } from "expo-status-bar";
|
||||||
import { ActivityIndicator, View, StyleSheet } from "react-native";
|
import { ActivityIndicator, View, StyleSheet } from "react-native";
|
||||||
import * as Updates from "expo-updates";
|
import * as Updates from "expo-updates";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { NavigationContainer } from "@react-navigation/native";
|
import { NavigationContainer } from "@react-navigation/native";
|
||||||
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
||||||
|
|
||||||
@@ -23,6 +24,8 @@ import type { AuthStackParamList } from "./src/navigation/types";
|
|||||||
|
|
||||||
const Stack = createNativeStackNavigator<AuthStackParamList>();
|
const Stack = createNativeStackNavigator<AuthStackParamList>();
|
||||||
|
|
||||||
|
const OTA_LAST_RELOAD_KEY = "ota_last_reload_update_id";
|
||||||
|
|
||||||
function AuthStack() {
|
function AuthStack() {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
@@ -97,10 +100,13 @@ export default function App() {
|
|||||||
const checkForUpdate = async () => {
|
const checkForUpdate = async () => {
|
||||||
try {
|
try {
|
||||||
const update = await Updates.checkForUpdateAsync();
|
const update = await Updates.checkForUpdateAsync();
|
||||||
if (update.isAvailable) {
|
const id = update.isAvailable ? update.manifest?.id : undefined;
|
||||||
|
if (!id || id === Updates.updateId) return;
|
||||||
|
// Déjà tentée : si elle ne tourne pas, on ne relance pas (évite la boucle)
|
||||||
|
if ((await AsyncStorage.getItem(OTA_LAST_RELOAD_KEY)) === id) return;
|
||||||
await Updates.fetchUpdateAsync();
|
await Updates.fetchUpdateAsync();
|
||||||
|
await AsyncStorage.setItem(OTA_LAST_RELOAD_KEY, id);
|
||||||
await Updates.reloadAsync();
|
await Updates.reloadAsync();
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[OTA] Échec de la vérification/application de la mise à jour:", e);
|
console.error("[OTA] Échec de la vérification/application de la mise à jour:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user