From 10f95b3ea34724bb0b511170ebc458a89a4e065d Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 23 Oct 2022 10:11:24 +0100 Subject: [PATCH] Handle display of deprecation after SW mode registration failure --- www/js/app.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 25150e41f..aa115a9bc 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -598,26 +598,24 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys '

If you experience problems with this mode, you can switch back to the (now deprecated) JQuery mode. ' + 'In that case, please report the problems you experienced to us (see About section).

', 'Change of default content injection mode']; - uiUtil.systemAlert(message[0], message[1]).then(function () { - params.defaultModeChangeAlertDisplayed = true; - settingsStore.setItem('defaultModeChangeAlertDisplayed', true, Infinity); - }); - + uiUtil.systemAlert(message[0], message[1]).then(function () { + settingsStore.setItem('defaultModeChangeAlertDisplayed', true, Infinity); + }); } else if (!params.defaultModeChangeAlertDisplayed && params.contentInjectionMode === 'jquery') { message = ['

Unfortunately, your browser does not appear to support ServiceWorker mode, which is now the default for this app.

' + '

You can continue to use the app in the (now deprecated) JQuery mode, but note that this mode only works well with ' + 'ZIM archives that have static content, such as Wikipedia / Wikimedia ZIMs or Stackexchange.

' + '

If you can, we recommend that you update your browser to a version that supports ServiceWorker mode.

', 'ServiceWorker mode unsupported']; - uiUtil.systemAlert(message[0], message[1], true, 'Cancel', 'Okay').then(function (result) { - if (result) { - // If user selected OK, then do not display again ever - settingsStore.setItem('defaultModeChangeAlertDisplayed', true, Infinity); - } - // This prevents the alert being displayed again this session - params.defaultModeChangeAlertDisplayed = true; - }); + uiUtil.systemAlert(message[0], message[1], true, 'Cancel', 'Okay').then(function (result) { + if (result) { + // If user selected OK, then do not display again ever + settingsStore.setItem('defaultModeChangeAlertDisplayed', true, Infinity); + } + }); } + // This prevents the alert being displayed again this session + params.defaultModeChangeAlertDisplayed = true; } /** @@ -911,6 +909,12 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys } uiUtil.systemAlert(message, "Failed to register ServiceWorker").then(function () { setContentInjectionMode('jquery'); + // We need to wait for the previous dialogue box to unload fully before attempting to display another + setTimeout(function () { + params.defaultModeChangeAlertDisplayed = false; + settingsStore.removeItem('defaultModeChangeAlertDisplayed'); + checkAndDisplayInjectionModeChangeAlert(); + }, 1200); }); } });