diff options
Diffstat (limited to 'misc/dist/html/editor.html')
-rw-r--r-- | misc/dist/html/editor.html | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html index 3a22055546..4f2a3bc053 100644 --- a/misc/dist/html/editor.html +++ b/misc/dist/html/editor.html @@ -363,24 +363,28 @@ window.addEventListener('load', () => { btn.style.display = ''; } if ('serviceWorker' in navigator) { - navigator.serviceWorker.register('service.worker.js').then(function (reg) { - if (reg.waiting) { - notifyUpdate(reg.waiting); - } - reg.addEventListener('updatefound', function () { - const update = reg.installing; - update.addEventListener('statechange', function () { - if (update.state === 'installed') { - // It's a new install, claim and perform aggressive caching. - if (!reg.active) { - update.postMessage('claim'); - } else { - notifyUpdate(update); + try { + navigator.serviceWorker.register('service.worker.js').then(function (reg) { + if (reg.waiting) { + notifyUpdate(reg.waiting); + } + reg.addEventListener('updatefound', function () { + const update = reg.installing; + update.addEventListener('statechange', function () { + if (update.state === 'installed') { + // It's a new install, claim and perform aggressive caching. + if (!reg.active) { + update.postMessage('claim'); + } else { + notifyUpdate(update); + } } - } + }); }); }); - }); + } catch (e) { + console.error('Error while registering service worker:', e); + } } const missing = Engine.getMissingFeatures({ |