Test add this as dep

This commit is contained in:
Lim Chee Aun 2023-03-24 01:04:47 +08:00
parent 5208df4a28
commit 11324364a5

View file

@ -193,24 +193,27 @@ function Timeline({
}, [nearReachEnd, showMore]); }, [nearReachEnd, showMore]);
const lastHiddenTime = useRef(); const lastHiddenTime = useRef();
usePageVisibility((visible) => { usePageVisibility(
if (visible) { (visible) => {
const timeDiff = Date.now() - lastHiddenTime.current; if (visible) {
if (!lastHiddenTime.current || timeDiff > 1000 * 60) { const timeDiff = Date.now() - lastHiddenTime.current;
(async () => { if (!lastHiddenTime.current || timeDiff > 1000 * 60) {
console.log('✨ Check updates'); (async () => {
const hasUpdate = await checkForUpdates(); console.log('✨ Check updates');
if (hasUpdate) { const hasUpdate = await checkForUpdates();
console.log('✨ Has new updates'); if (hasUpdate) {
setShowNew(true); console.log('✨ Has new updates');
} setShowNew(true);
})(); }
})();
}
} else {
lastHiddenTime.current = Date.now();
} }
} else { setVisible(visible);
lastHiddenTime.current = Date.now(); },
} [checkForUpdates],
setVisible(visible); );
}, []);
// checkForUpdates interval // checkForUpdates interval
useInterval( useInterval(