From b1324e164f937f19d6e31e7ec1cac1a0da407156 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Thu, 15 Dec 2022 20:52:23 +0000 Subject: [PATCH] Handle comparison between -app_maxi and _maxi archives better Fixes #325 Former-commit-id: ac124c1b8c7058de6526713417191fa0762980e0 --- www/js/app.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 37b7ac42..39ee8de9 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -2393,17 +2393,17 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images typeof window.fs !== 'undefined' || typeof window.showOpenFilePicker !== 'undefined') { if (!params.pickedFile && window.fs) { // Below we compare the prefix of the files, i.e. the generic filename without date, so we can smoothly deal with upgrades - if (params.packagedFile && params.storedFile.replace(/_[\d-]+\.zim\w?\w?$/i, '') === params.packagedFile.replace(/_[\d-]+\.zim\w?\w?$/i, '')) { + if (params.packagedFile && params.storedFile.replace(/(?:[_-]app)?_maxi_[\d-]+\.zim\w?\w?$/i, '') === params.packagedFile.replace(/(?:[_-]app_)?_maxi_[\d-]+\.zim\w?\w?$/i, '')) { // We're in Electron / NWJS and we need to load the packaged app, so we are forced to use the .fs code params.pickedFile = params.packagedFile; + } else if (!params.storedFile) { + // If there is no last selected archive, we need to use the .fs code anyway + params.pickedFile = params.packagedFile; } - // else if (!window.showOpenFilePicker || !window.nw ) { - // // We're in an Electron app, or an older NWJS app, so we need to use the .fs code anyway - // params.pickedFile = params.storedFile; - // } } if (!params.pickedFile) { if (params.storedFile && window.showOpenFilePicker) { + // We are in an app with support for File System Access API, so we can't auto-load the file, show file pickers document.getElementById('btnConfigure').click(); } else { searchForArchivesInPreferencesOrStorage();