From 67d2fb4366cbda25c863cf7c6cc0318f3c25df16 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 21 Jan 2023 08:45:19 +0000 Subject: [PATCH] Give more time for Service Worker to load --- www/js/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 346dee26..983e6c5a 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -4991,7 +4991,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images return encodeURIComponent(m); }); - if (params.contentInjectionMode === 'serviceworker' && navigator.serviceWorker.controller) { + if (params.contentInjectionMode === 'serviceworker') { // Remove page max width restriction if required if (params.removePageMaxWidth) htmlArticle = removePageMaxWidth(htmlArticle); // For UWP apps, we need to add the Zoom level to the HTML if we are opening in external window @@ -5019,7 +5019,11 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images if (!appstate.messageChannelWaiting) { // We put the ZIM filename as a prefix in the URL, so that browser caches are separate for each ZIM file var newLocation = "../" + appstate.selectedArchive._file.name + "/" + dirEntry.namespace + "/" + encodedUrl; - articleWindow.location.href = newLocation; + if (navigator.serviceWorker.controller) articleWindow.location.href = newLocation; + else setTimeout(function () { + // The Service Worker needs more time to load + articleWindow.location.href = newLocation; + }, 0); } return; }