@@ -5,6 +5,11 @@ import useIdle from "./useIdle";
|
||||
import useInterval from "./useInterval";
|
||||
import usePageVisibility from "./usePageVisibility";
|
||||
|
||||
// The case of isReloaded=true should never be hit as the app will reload
|
||||
// before the hook is called again, however seems like the only possible
|
||||
// cause of #5384, adding to debug.
|
||||
let isReloaded = false;
|
||||
|
||||
/**
|
||||
* Hook to reload the app around once a day to stop old code from running.
|
||||
*/
|
||||
@@ -25,9 +30,14 @@ export default function useAutoRefresh() {
|
||||
Logger.debug("lifecycle", "Skipping reload due to user activity");
|
||||
return;
|
||||
}
|
||||
if (isReloaded) {
|
||||
Logger.error("lifecycle", new Error("Attempted to reload twice"));
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.debug("lifecycle", "Auto-reloading app…");
|
||||
window.location.reload();
|
||||
isReloaded = true;
|
||||
}
|
||||
}, Minute);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user