From b1847c45751da2230b120969d9c90ae90911694c Mon Sep 17 00:00:00 2001 From: Stephan-Thomas Date: Tue, 28 Jul 2026 10:54:20 +0100 Subject: [PATCH] fix(navbar): pause notification interval when document is not visible --- frontend/src/components/Navbar.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index b8ec0f17..f9737952 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -36,12 +36,20 @@ export default function Navbar() { setNotifications([]); return; } - const fetchNotifs = () => + const fetchNotifs = () => { + if (document.visibilityState !== 'visible') return; api .getNotifications() .then(setNotifications) .catch(() => {}); - fetchNotifs(); + }; + + // Initial fetch + api + .getNotifications() + .then(setNotifications) + .catch(() => {}); + const id = setInterval(fetchNotifs, 30_000); return () => clearInterval(id); }, [user]);