mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-23 01:35:38 +03:00
Just sub it once
This commit is contained in:
parent
c9124bf150
commit
8b5fee3dfd
1 changed files with 8 additions and 13 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue