Just sub it once

pull/493/head
Lim Chee Aun 2024-04-10 17:31:26 +08:00
rodzic c9124bf150
commit 8b5fee3dfd
1 zmienionych plików z 8 dodań i 13 usunięć

Wyświetl plik

@ -247,7 +247,6 @@ function Notifications({ columnMode }) {
const lastHiddenTime = useRef();
usePageVisibility((visible) => {
let unsub;
if (visible) {
const timeDiff = Date.now() - lastHiddenTime.current;
if (!lastHiddenTime.current || timeDiff > 1000 * 3) {
@ -258,20 +257,16 @@ function Notifications({ columnMode }) {
} else {
lastHiddenTime.current = Date.now();
}
unsub = subscribeKey(states, 'notificationsShowNew', (v) => {
if (uiState === 'loading') {
return;
}
if (v) {
loadUpdates();
}
setShowNew(v);
});
}
return () => {
unsub?.();
};
});
useEffect(() => {
let unsub = subscribeKey(states, 'notificationsShowNew', (v) => {
if (uiState === 'loading') return;
if (v) loadUpdates();
setShowNew(v);
});
return () => unsub?.();
}, []);
const todayDate = new Date();
const yesterdayDate = new Date(todayDate - 24 * 60 * 60 * 1000);