const isFirstRender = useRef(true); useEffect(() => { if (isFirstRender.current) { isFirstRender.current = false; return; } const runSomeBs = async () => { if (isOffline) { Toast.show({ type: "info", text1: "Starting round", text2: "You are now in offline mode", }); onlineManager.setOnline(false); } else { Toast.show({ type: "info", text1: "Ending round", text2: "You are now in online mode. Data is syncing...", }); console.log("CALL MUTATION STUFF"); onlineManager.setOnline(true); console.log(queryClient.getMutationCache().getAll()); const what = await queryClient.resumePausedMutations(); console.log(what); } }; runSomeBs(); }, [isOffline]); // const backgroundTask = async () => { // if (networkContext.isOffline) { // queryClient.resumePausedMutations(); // } // }; // useEffect(() => { // BackgroundFetch.configure( // { // minimumFetchInterval: 15, // }, // async (taskId) => { // console.log("[js] RNBackgroundFetch starting"); // await backgroundTask(); // BackgroundFetch.finish(taskId); // }, // (error) => { // console.log("[js] RNBackgroundFetch failed to start"); // } // ); // return () => { // BackgroundFetch.stop(); // }; // }, []); useEffect(() => { const loadAuthToken = async () => { const authToken = await AsyncStorage.getItem("authToken"); const authTokenExpirationTime = await AsyncStorage.getItem( "authTokenExpirationTime" ); const currentTime = new Date().getTime(); if ( authToken && authTokenExpirationTime && currentTime < Number(authTokenExpirationTime) ) { // If the auth token is not expired, set it in the auth context authContext?.setAuthToken(authToken); } else { // If the auth token is expired, remove it from AsyncStorage await AsyncStorage.removeItem("authToken"); await AsyncStorage.removeItem("authTokenExpirationTime"); } }; loadAuthToken(); }, []); const colorScheme = useColorScheme(); if (!authContext?.authToken) { return (