From 6a4934b63e479ece8b46d440a50659cfec743e6e Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 1 Dec 2024 09:04:52 +0000 Subject: [PATCH] Do not intercept reload if app has FS Access Fixes #673 --- www/js/init.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/js/init.js b/www/js/init.js index e3eedd6d4..9275f46ff 100644 --- a/www/js/init.js +++ b/www/js/init.js @@ -34,7 +34,9 @@ window.onerror = function (msg, url, line, col, error) { // Set a beforeUnload handler to prevent app reloads without confirmation if a ZIM file is loaded window.addEventListener('beforeunload', function (event) { - if (params.interceptBeforeUnload && !params.useOPFS && appstate && appstate.selectedArchive && params.appCache && !/Electron/.test(params.appType)) { + if (params.interceptBeforeUnload && !params.useOPFS && params.appCache && !/UWP|Electron/.test(params.appType)) { + if (!appstate.selectedArchive) return; // No need to intercept if no archive is loaded + if (params.pickedFile || params.pickedFolder) return; // No need to intercept if we have FS access to a file or folder var confirmationMessage = 'Warning: you may have to reload the ZIM archive if you leave this page!'; event.preventDefault(); // Included for legacy support, e.g. Chrome/Edge < 119