mirror of
https://github.com/myronblair/jarvis
synced 2026-07-29 01:03:14 -05:00
Add idle reload: full page refresh after 5min inactivity
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user