From 4d89dae16905598c2798fdae99f1156996ab8102 Mon Sep 17 00:00:00 2001 From: Xor290 Date: Wed, 11 Nov 2026 16:27:00 +0100 Subject: [PATCH] chore: build --- frontend-admin/App.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend-admin/App.tsx b/frontend-admin/App.tsx index 9465bb05..697d7961 100644 --- a/frontend-admin/App.tsx +++ b/frontend-admin/App.tsx @@ -2,6 +2,7 @@ import React, { useMemo, useEffect } from "react"; import { StatusBar } from "expo-status-bar"; import { ActivityIndicator, View, StyleSheet } from "react-native"; import * as Updates from "expo-updates"; +import AsyncStorage from "@react-native-async-storage/async-storage"; import { NavigationContainer } from "@react-navigation/native"; import { createNativeStackNavigator } from "@react-navigation/native-stack"; @@ -23,6 +24,8 @@ import type { AuthStackParamList } from "./src/navigation/types"; const Stack = createNativeStackNavigator(); +const OTA_LAST_RELOAD_KEY = "ota_last_reload_update_id"; + function AuthStack() { const { colors } = useTheme(); @@ -97,10 +100,13 @@ export default function App() { const checkForUpdate = async () => { try { const update = await Updates.checkForUpdateAsync(); - if (update.isAvailable) { - await Updates.fetchUpdateAsync(); - await Updates.reloadAsync(); - } + 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 AsyncStorage.setItem(OTA_LAST_RELOAD_KEY, id); + await Updates.reloadAsync(); } catch (e) { console.error("[OTA] Échec de la vérification/application de la mise à jour:", e); }