Just sub it once
This commit is contained in:
parent
c9124bf150
commit
8b5fee3dfd
|
@ -247,7 +247,6 @@ function Notifications({ columnMode }) {
|
||||||
|
|
||||||
const lastHiddenTime = useRef();
|
const lastHiddenTime = useRef();
|
||||||
usePageVisibility((visible) => {
|
usePageVisibility((visible) => {
|
||||||
let unsub;
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
const timeDiff = Date.now() - lastHiddenTime.current;
|
const timeDiff = Date.now() - lastHiddenTime.current;
|
||||||
if (!lastHiddenTime.current || timeDiff > 1000 * 3) {
|
if (!lastHiddenTime.current || timeDiff > 1000 * 3) {
|
||||||
|
@ -258,20 +257,16 @@ function Notifications({ columnMode }) {
|
||||||
} else {
|
} else {
|
||||||
lastHiddenTime.current = Date.now();
|
lastHiddenTime.current = Date.now();
|
||||||
}
|
}
|
||||||
unsub = subscribeKey(states, 'notificationsShowNew', (v) => {
|
|
||||||
if (uiState === 'loading') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (v) {
|
|
||||||
loadUpdates();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
useEffect(() => {
|
||||||
|
let unsub = subscribeKey(states, 'notificationsShowNew', (v) => {
|
||||||
|
if (uiState === 'loading') return;
|
||||||
|
if (v) loadUpdates();
|
||||||
setShowNew(v);
|
setShowNew(v);
|
||||||
});
|
});
|
||||||
}
|
return () => unsub?.();
|
||||||
return () => {
|
}, []);
|
||||||
unsub?.();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const todayDate = new Date();
|
const todayDate = new Date();
|
||||||
const yesterdayDate = new Date(todayDate - 24 * 60 * 60 * 1000);
|
const yesterdayDate = new Date(todayDate - 24 * 60 * 60 * 1000);
|
||||||
|
|
Loading…
Reference in a new issue