Skip to content

Commit

Permalink
Handle display of deprecation after SW mode registration failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Oct 23, 2022
1 parent 651dafd commit 10f95b3
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,26 +598,24 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
'<p>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).</p>',
'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 = ['<p>Unfortunately, your browser does not appear to support ServiceWorker mode, which is now the default for this app.</p>' +
'<p>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.</p>' +
'<p>If you can, we recommend that you update your browser to a version that supports ServiceWorker mode.</p>',
'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;
}

/**
Expand Down Expand Up @@ -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);
});
}
});
Expand Down

0 comments on commit 10f95b3

Please sign in to comment.