diff --git a/src/views/account/Restaurant/Modals/QrCode.tsx b/src/views/account/Restaurant/Modals/QrCode.tsx index c996e941c..d70bad9ff 100644 --- a/src/views/account/Restaurant/Modals/QrCode.tsx +++ b/src/views/account/Restaurant/Modals/QrCode.tsx @@ -6,6 +6,7 @@ import { TouchableOpacity, StyleSheet, ScrollView, Platform, + AppState, } from "react-native"; import { DeviceMotion } from "expo-sensors"; import { SafeAreaView } from "react-native-safe-area-context"; @@ -59,6 +60,29 @@ const RestaurantQrCode: Screen<"RestaurantQrCode"> = ({ route, navigation }) => const [oldBrightness, setOldBrightness] = useState(0.5); useEffect(() => { + let isActive = true; + + const handleAppStateChange = async (nextAppState: string) => { + if (nextAppState === "background" || nextAppState === "inactive") { + if (isActive) { + isActive = false; + await Brightness.setBrightnessAsync(oldBrightness); + } + } else if (nextAppState === "active") { + isActive = true; + await Brightness.setBrightnessAsync(1); + } + }; + + const appStateSubscription = AppState.addEventListener( + "change", + handleAppStateChange + ); + + const navigationSubscription = navigation.addListener("beforeRemove", () => { + Brightness.setBrightnessAsync(oldBrightness); + }); + (async () => { if (Platform.OS === "android") { const { status } = await Brightness.requestPermissionsAsync(); @@ -73,7 +97,11 @@ const RestaurantQrCode: Screen<"RestaurantQrCode"> = ({ route, navigation }) => await Brightness.setBrightnessAsync(1); } catch (e) { console.warn("Brightness error:", e); } })(); - return () => { Brightness.setBrightnessAsync(oldBrightness); }; + return () => { + appStateSubscription.remove(); + navigationSubscription(); + Brightness.setBrightnessAsync(oldBrightness); + }; }, [navigation, oldBrightness]); diff --git a/src/views/settings/ExternalAccount/Turboself.tsx b/src/views/settings/ExternalAccount/Turboself.tsx index dbdc10d03..aa8d78add 100644 --- a/src/views/settings/ExternalAccount/Turboself.tsx +++ b/src/views/settings/ExternalAccount/Turboself.tsx @@ -40,6 +40,9 @@ const ExternalTurboselfLogin: Screen<"ExternalTurboselfLogin"> = ({ navigation } } catch (error) { if (error instanceof Error) { setError(error.message); + if (error.message == "401: {\"statusCode\":401,\"message\":\"Accès interdit\"}") { + setError("Nom d'utilisateur ou mot de passe incorrect"); + }; } else { setError("Une erreur est survenue lors de la connexion.");