Skip to content

Commit aba0637

Browse files
Update index.js
1 parent b815922 commit aba0637

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

js/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,19 @@ function setupServiceWorkerUpdateListener() {
605605
if (!('serviceWorker' in navigator)) return;
606606

607607
// Load Version Info on startup
608-
updateSystemVersionUI();
608+
updateSystemVersionUI().then(() => {
609+
// Daily Auto-Check Logic
610+
const lastCheck = parseInt(localStorage.getItem('last_sw_check') || '0');
611+
const ONE_DAY = 24 * 60 * 60 * 1000;
612+
613+
if (Date.now() - lastCheck > ONE_DAY) {
614+
console.log("[System] Running scheduled daily update check...");
615+
navigator.serviceWorker.getRegistration().then(reg => {
616+
if (reg) reg.update();
617+
localStorage.setItem('last_sw_check', Date.now().toString());
618+
});
619+
}
620+
});
609621

610622
const isUpdate = navigator.serviceWorker.controller !== null;
611623

@@ -622,10 +634,11 @@ function setupServiceWorkerUpdateListener() {
622634
}
623635

624636
const showUpdateNotification = () => {
625-
showNotification(`Update available: Polygol`, {
626-
icon: 'system_update',
637+
showNotification(`A new system update is ready to install. (Version ${newV})`, {
638+
header: 'System update',
639+
icon: 'update',
627640
system: true,
628-
buttonText: 'Restart',
641+
buttonText: 'Restart and Install',
629642
buttonAction: () => {
630643
worker.postMessage({ action: 'skipWaiting' });
631644
}

0 commit comments

Comments
 (0)