From 2e51b082a7481da70b75a005627ad5db5cddb30a Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Wed, 22 Nov 2023 17:52:49 +0000 Subject: [PATCH] Fix anomalous boot loop when app is in jQuery mode and no SW is registered (#1170) --- www/js/app.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 9b2b5c7b1..d0f289932 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -841,14 +841,27 @@ function initServiceWorkerMessaging () { }); } else if (serviceWorkerRegistration) { // If this is the first time we are initiating the SW, allow Promises to complete by delaying potential reload till next tick - console.warn('The Service Worker needs more time to load, or else the app was force-refrshed...'); + console.warn('The Service Worker needs more time to load, or else the app was force-refreshed...'); serviceWorkerRegistration = null; - setTimeout(initServiceWorkerMessaging, 1200); - } else { + setTimeout(initServiceWorkerMessaging, 1600); + } else if (params.contentInjectionMode === 'serviceworker') { console.error('The Service Worker is not controlling the current page! We have to reload.'); // Turn off failsafe, as this is a controlled reboot settingsStore.setItem('lastPageLoad', 'rebooting', Infinity); window.location.reload(); + } else if (navigator && navigator.serviceWorker && !navigator.serviceWorker.controller) { + uiUtil.systemAlert('

No Service Worker is registered, meaning this app will not currently work offline!

Would you like to switch to ServiceWorker mode?

', + 'Offline use is disabled!', true).then(function (response) { + if (response) { + setContentInjectionMode('serviceworker'); + if (selectedArchive) { + setTimeout(function () { + params.themeChanged = true; + document.getElementById('btnHome').click(); + }, 750); + } + } + }); } }