diff --git a/public/s/js/settings.js b/public/s/js/settings.js index cef531e..3aae817 100644 --- a/public/s/js/settings.js +++ b/public/s/js/settings.js @@ -1815,9 +1815,12 @@ const streamUrl = `/api/v2/export/stream?id=${streamId}&filename=${encodeURIComponent(suggestedFileName)}`; const worker = new Worker(URL.createObjectURL(new Blob([workerCode], { type: 'application/javascript' }))); - // The SW must be controlling this page to intercept /api/v2/export/stream. - // .controller is null after hard refresh — in that case, reload once. - const sw = navigator.serviceWorker.controller; + // The SW must be controlling this page or be active to intercept /api/v2/export/stream. + let sw = navigator.serviceWorker.controller; + if (!sw) { + const reg = await navigator.serviceWorker.getRegistration('/api/v2/export/'); + sw = reg ? reg.active : null; + } if (!sw) { worker.terminate(); exportStatusMsg.textContent = 'Reloading to activate Service Worker...'; diff --git a/views/snippets/footer.html b/views/snippets/footer.html index 2b92566..b1b9b30 100644 --- a/views/snippets/footer.html +++ b/views/snippets/footer.html @@ -618,10 +618,33 @@