From ffde4eaf6021704e9568dc6528f99037205cf293 Mon Sep 17 00:00:00 2001 From: bloqaudio Date: Mon, 14 Sep 2026 14:06:41 -0500 Subject: [PATCH] web: stop polling when the page has had no input for ten minutes The firmware counts every authenticated request as session activity, and the page polls the status every 2.5 s, so an open tab never let the session expire. Track the last mouse, key, touch or wheel event and treat the page as hidden once ten minutes have passed without one: the pollers keep ticking but send nothing, the session times out in the firmware as it did before, and the next input resumes polling, which meets the 401 and returns to the login page. --- html/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/html/app.js b/html/app.js index 0a50b322..9a5f663c 100644 --- a/html/app.js +++ b/html/app.js @@ -533,13 +533,18 @@ TABS.forEach(function(tb){ }); $("burger").addEventListener("click",function(){$("nav").classList.toggle("open")}); +var IDLE_STOP_MS=600000,lastInput=Date.now(); +["mousemove","mousedown","keydown","touchstart","wheel"].forEach(function(ev){ + addEventListener(ev,function(){lastInput=Date.now()},{passive:true}); +}); function Poller(fn,ms){this.fn=fn;this.ms=ms;this.on=false;this.t=null} Poller.prototype.start=function(){if(this.on)return;this.on=true;this.tick()}; Poller.prototype.stop=function(){this.on=false;clearTimeout(this.t)}; Poller.prototype.tick=function(){ var self=this; if(!self.on)return; - var run=document.hidden?Promise.resolve():Promise.resolve().then(self.fn).catch(function(){}); + var quiet=document.hidden||Date.now()-lastInput>IDLE_STOP_MS; + var run=quiet?Promise.resolve():Promise.resolve().then(self.fn).catch(function(){}); run.then(function(){ if(self.on)self.t=setTimeout(function(){self.tick()},self.ms); }); };