Skip to content

Commit

Permalink
Check for update on resume
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf committed Jul 13, 2023
1 parent 2010db9 commit d7fc6b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Start.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ErrorBoundary } from "react-error-boundary";
import { AppState, useColorScheme } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import merge from "deepmerge";
import codePush from "react-native-code-push";
import Stack from "./Stack";
import MemmyErrorView from "./src/components/common/Loading/MemmyErrorView";
import { writeToLog } from "./src/helpers/LogHelper";
Expand Down Expand Up @@ -71,6 +72,7 @@ function Start() {
const appState = useRef(AppState.currentState);

let refreshInterval;
let updateInterval;

useEffect(() => {
if (!loaded) return;
Expand All @@ -85,12 +87,14 @@ function Start() {
) {
writeToLog("Starting refresh interval.");
startInterval();
codePush.checkForUpdate().then();
} else if (
appState.current === "active" &&
nextAppState.match(/inactive|background/)
) {
writeToLog("Ending refresh interval.");
clearInterval(refreshInterval);
clearInterval(updateInterval);
refreshInterval = null;
}

Expand Down

0 comments on commit d7fc6b3

Please sign in to comment.