diff options
author | Keegan McGonigle <31631874+thedinosoar@users.noreply.github.com> | 2024-10-10 11:21:50 -0700 |
---|---|---|
committer | Keegan McGonigle <31631874+thedinosoar@users.noreply.github.com> | 2024-10-22 10:28:21 -0700 |
commit | 05b266bd8950330935c51938e0ebe159d87316c8 (patch) | |
tree | 77d482d5193b84d4defec716ade75dd2adc38f3a /misc/dist/html/editor.html | |
parent | b3bcb2dc14691f7729984128dca26a844f662fa1 (diff) | |
download | redot-engine-05b266bd8950330935c51938e0ebe159d87316c8.tar.gz |
Fix PWA callback assignment and error handling
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({ |