mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-25 06:54:43 +01:00
Debounce page visibility to prevent streaming/polling noise
This commit is contained in:
parent
ef0d9cd810
commit
6930ce9a7c
2 changed files with 14 additions and 3 deletions
|
@ -16,7 +16,18 @@ export default memo(function BackgroundService({ isLoggedIn }) {
|
||||||
// Notifications service
|
// Notifications service
|
||||||
// - WebSocket to receive notifications when page is visible
|
// - WebSocket to receive notifications when page is visible
|
||||||
const [visible, setVisible] = useState(true);
|
const [visible, setVisible] = useState(true);
|
||||||
usePageVisibility(setVisible);
|
const visibleTimeout = useRef();
|
||||||
|
usePageVisibility((visible) => {
|
||||||
|
clearTimeout(visibleTimeout.current);
|
||||||
|
if (visible) {
|
||||||
|
setVisible(true);
|
||||||
|
} else {
|
||||||
|
visibleTimeout.current = setTimeout(() => {
|
||||||
|
setVisible(false);
|
||||||
|
}, POLL_INTERVAL);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const checkLatestNotification = async (masto, instance, skipCheckMarkers) => {
|
const checkLatestNotification = async (masto, instance, skipCheckMarkers) => {
|
||||||
if (states.notificationsLast) {
|
if (states.notificationsLast) {
|
||||||
const notificationsIterator = masto.v1.notifications.list({
|
const notificationsIterator = masto.v1.notifications.list({
|
||||||
|
|
|
@ -511,11 +511,11 @@ msgstr ""
|
||||||
msgid "server domain name"
|
msgid "server domain name"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/background-service.jsx:138
|
#: src/components/background-service.jsx:149
|
||||||
msgid "Cloak mode disabled"
|
msgid "Cloak mode disabled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/background-service.jsx:138
|
#: src/components/background-service.jsx:149
|
||||||
msgid "Cloak mode enabled"
|
msgid "Cloak mode enabled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue