Skip to content

Commit

Permalink
fix: 🐛 Corrige l'erreur Sentry : Current activity not found (#1718)
Browse files Browse the repository at this point in the history
Closes: #1254
  • Loading branch information
benguedj authored Jul 24, 2023
1 parent 45bb865 commit 03690e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 14 additions & 3 deletions front/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { StatusBar } from "expo-status-bar";
import type { FC } from "react";
import * as React from "react";
Expand Down Expand Up @@ -30,6 +31,9 @@ import {
TrackerUtils,
} from "./src/utils";

// Keep the splash screen visible while we fetch resources
void SplashScreen.preventAutoHideAsync();

setNotificationHandler();
initLocales();
initMonitoring();
Expand Down Expand Up @@ -138,17 +142,24 @@ const MainAppContainer: FC = () => {

void init();
// Permet de détecter lorsque l'app change d'état ('active' | 'background' | 'inactive' | 'unknown' | 'extension')
AppState.addEventListener("change", handleAppStateChange);
const subscription = AppState.addEventListener(
"change",
handleAppStateChange
);

return () => {
AppState.removeEventListener("change", handleAppStateChange);
subscription.remove();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (isLoadingComplete && fontsLoaded && appCounterIsLoaded) {
setScreenCanBeDisplayed(true);
const hideSplashScreen = async () => {
await SplashScreen.hideAsync();
setScreenCanBeDisplayed(true);
};
void hideSplashScreen();
}
}, [isLoadingComplete, fontsLoaded, appCounterIsLoaded]);

Expand Down
4 changes: 0 additions & 4 deletions front/src/hooks/useCachedResources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Ionicons } from "@expo/vector-icons";
import * as Font from "expo-font";
import * as SplashScreen from "expo-splash-screen";
import { useEffect, useState } from "react";

const useCachedResources = (): boolean => {
Expand All @@ -10,8 +9,6 @@ const useCachedResources = (): boolean => {
useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
void SplashScreen.preventAutoHideAsync();

// Load fonts
await Font.loadAsync({
...Ionicons.font,
Expand All @@ -34,7 +31,6 @@ const useCachedResources = (): boolean => {
console.warn(error);
} finally {
setLoadingComplete(true);
void SplashScreen.hideAsync();
}
}

Expand Down

0 comments on commit 03690e1

Please sign in to comment.