From b806586a5a2569ba921883bf1fda70c19227e9c0 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Sun, 23 Feb 2025 18:13:41 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B4=D0=B8=D0=B0=D0=B3=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=B0=D0=BA=D1=82=D0=B8=D0=B2=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/view/podkop/podkop.js | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js index 1e5b3e9..f1f05f9 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js @@ -1004,9 +1004,41 @@ return view.extend({ // Start periodic updates function startPeriodicUpdates() { + let intervalId = null; + let isVisible = true; + + // Initial update updateDiagnostics(); - const intervalId = setInterval(updateDiagnostics, 10000); - window.addEventListener('unload', () => clearInterval(intervalId)); + + // Handle visibility change + document.addEventListener('visibilitychange', () => { + isVisible = document.visibilityState === 'visible'; + if (isVisible) { + // Tab became visible - do immediate update and restart interval + updateDiagnostics(); + if (intervalId === null) { + intervalId = setInterval(updateDiagnostics, 10000); + } + } else { + // Tab hidden - clear interval + if (intervalId !== null) { + clearInterval(intervalId); + intervalId = null; + } + } + }); + + // Start interval if page is visible + if (isVisible) { + intervalId = setInterval(updateDiagnostics, 10000); + } + + // Cleanup on page unload + window.addEventListener('unload', () => { + if (intervalId !== null) { + clearInterval(intervalId); + } + }); } // Extra Section