Add idle reload: full page refresh after 5min inactivity

This commit is contained in:
2026-05-30 01:47:59 +00:00
parent a1b4e49a9c
commit 5cbcae6055
+7 -1
View File
@@ -885,10 +885,15 @@ let faceLoopId = null;
let lastFaceSeen = 0; let lastFaceSeen = 0;
let autoMicCooldown = 0; let autoMicCooldown = 0;
let faceApiReady = false; let faceApiReady = false;
let lastActivity = Date.now();
const IDLE_RELOAD_MS = 5 * 60 * 1000; // 5 min inactivity → full reload
const FACE_MODEL_URL = 'https://cdn.jsdelivr.net/gh/justadudewhohacks/face-api.js@0.22.2/weights'; const FACE_MODEL_URL = 'https://cdn.jsdelivr.net/gh/justadudewhohacks/face-api.js@0.22.2/weights';
// ── INIT ───────────────────────────────────────────────────────────── // ── INIT ─────────────────────────────────────────────────────────────
window.addEventListener('load', () => { window.addEventListener("load", () => {
["mousemove","keydown","touchstart","click"].forEach(e =>
window.addEventListener(e, () => { lastActivity = Date.now(); }, {passive:true})
);
updateClock(); updateClock();
setInterval(updateClock, 1000); setInterval(updateClock, 1000);
initVoice(); initVoice();
@@ -954,6 +959,7 @@ function showApp(name, greeting) {
// Start data refresh // Start data refresh
refreshAll(); refreshAll();
refreshTimer = setInterval(refreshAll, 10000); // every 10s refreshTimer = setInterval(refreshAll, 10000); // every 10s
setInterval(() => { if (Date.now() - lastActivity > IDLE_RELOAD_MS) location.reload(); }, 30000);
loadNetwork(); loadNetwork();
loadHA(); loadHA();
checkAgentStatus(); checkAgentStatus();