summaryrefslogtreecommitdiffstats
path: root/misc/dist/html/editor.html
diff options
context:
space:
mode:
authorKeegan McGonigle <31631874+thedinosoar@users.noreply.github.com>2024-10-10 11:21:50 -0700
committerKeegan McGonigle <31631874+thedinosoar@users.noreply.github.com>2024-10-22 10:28:21 -0700
commit05b266bd8950330935c51938e0ebe159d87316c8 (patch)
tree77d482d5193b84d4defec716ade75dd2adc38f3a /misc/dist/html/editor.html
parentb3bcb2dc14691f7729984128dca26a844f662fa1 (diff)
downloadredot-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.html34
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({