Auto-refresh dati ogni 10 min + visibilitychange
- setInterval ogni 10 minuti ricarica la pagina corrente (dashboard, inventario, spesa) silenziosamente, senza reload — i contatori di scadenza restano sempre aggiornati anche se la scheda è aperta da ore - visibilitychange ora aggiorna SEMPRE la pagina corrente, non solo la lista spesa, quando la tab torna in foreground
This commit is contained in:
+13
-3
@@ -8620,12 +8620,22 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
initScreensaverShortcuts();
|
initScreensaverShortcuts();
|
||||||
startBgShoppingRefresh();
|
startBgShoppingRefresh();
|
||||||
|
|
||||||
// Auto-refresh Bring list when user returns to the browser tab (e.g. was in the Bring app)
|
// ── Auto-refresh dati ogni 10 minuti ──────────────────────────────────
|
||||||
|
// Garantisce che scadenze e contatori si aggiornino anche senza toccare
|
||||||
|
// la schermata (es. pagina aperta tutta la notte).
|
||||||
|
const DATA_REFRESH_INTERVAL = 10 * 60 * 1000; // 10 minuti
|
||||||
|
setInterval(() => {
|
||||||
|
if (!_screensaverActive) {
|
||||||
|
refreshCurrentPage();
|
||||||
|
}
|
||||||
|
}, DATA_REFRESH_INTERVAL);
|
||||||
|
// Aggiorna anche quando la tab torna visibile dopo essere stata in background
|
||||||
document.addEventListener('visibilitychange', () => {
|
document.addEventListener('visibilitychange', () => {
|
||||||
if (!document.hidden && _currentPageId === 'shopping') {
|
if (!document.hidden) {
|
||||||
loadShoppingList();
|
refreshCurrentPage();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
// Silent background sync: update urgency specs on Bring and add missing critical items
|
// Silent background sync: update urgency specs on Bring and add missing critical items
|
||||||
// Runs once at startup (time-gated: max every 10 min) without affecting the UI
|
// Runs once at startup (time-gated: max every 10 min) without affecting the UI
|
||||||
|
|||||||
Reference in New Issue
Block a user