···36 }
37}
3839+let autoreg;
40async function subscribeToPush() {
41 const registration = await navigator.serviceWorker.register('/service-worker.js');
42+43+ // auto-update in case they keep it open in a tab for a long time
44+ clearInterval(autoreg);
45+ autoreg = setInterval(() => registration.update(), 4 * 60 * 60 * 1000); // every 4h
4647 const subscribeOptions = {
48 userVisibleOnly: true,