From 441fcce1c29137c4f7abcdae608a53846ba0c41e Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 31 Jan 2021 09:01:17 +0000 Subject: [PATCH] Move lastPageVisit code to init.js Former-commit-id: 98242d5486e3e576174e512db130e2d915258de4 [formerly df1a2035fbdb8391a5029ec2d82eccc0337d7926] [formerly dff7c504e3eb7fc96586a6273dd74aec063a6ee7] [formerly 14ec1165f0f70cd3017ac24c560b879344a66af1 [formerly 4318f1b8b8c862bb2dce86fcd0d9f0d209d289fa [formerly 3ae07de04638c096a7c83319cd8109080b65255a]]] Former-commit-id: 7aa59b369010499edc3e807bc972b1409e3a6690 [formerly 54bb3fe489f66397d0c251fc511b4a1b9c25cc07 [formerly 2dd565d931d7915cbb388e516c5f0e7c5b748b7d]] Former-commit-id: d7fb889aad3490c910df41e50c620535b7cc0f9b [formerly b555f615c63fd71c0b52bb82d37e29642f9f3ec0] Former-commit-id: 8811841362794324080f282a6c9513a2a447a580 --- pwabuilder-sw.js | 2 +- www/js/app.js | 3 --- www/js/init.js | 9 +++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pwabuilder-sw.js b/pwabuilder-sw.js index 5451fa5f..6d8d4019 100644 --- a/pwabuilder-sw.js +++ b/pwabuilder-sw.js @@ -4,7 +4,7 @@ // App version number - ENSURE IT MATCHES VALUE IN init.js // DEV: Changing this will cause the browser to recognize that the Service Worker has changed, and it will download and // install a new copy -const appVersion = '1.2.0-RP18'; +const appVersion = '1.2.0-RP19'; // Kiwix ZIM Archive Download Server in regex form // DEV: The server URL is defined in init.js, but is not available to us in SW diff --git a/www/js/app.js b/www/js/app.js index f150589a..9a34e861 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -58,9 +58,6 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett params['storeType'] = settingsStore.getBestAvailableStorageAPI(); // Test caching capability cache.test(function(){}); - params['lastPageVisit'] = params.storedFile ? settingsStore.getItem(params.storedFile) : ''; - params.lastPageVisit = params.lastPageVisit ? params.lastPageVisit + '@kiwixKey@' + params.storedFile : ''; - // Unique identifier of the article expected to be displayed var expectedArticleURLToBeDisplayed = ""; diff --git a/www/js/init.js b/www/js/init.js index 94842b86..b6382ae2 100644 --- a/www/js/init.js +++ b/www/js/init.js @@ -49,7 +49,7 @@ var params = {}; */ var appstate = {}; /******** UPDATE VERSION IN pwabuilder-sw.js TO MATCH VERSION *******/ -params['version'] = "1.2.0-RP18"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js +params['version'] = "1.2.0-RP19"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js /******* UPDATE THIS ^^^^^^ IN serveice worker!! ********************/ params['packagedFile'] = "wikipedia_en_100_maxi.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory) @@ -73,7 +73,6 @@ params['cssUITheme'] = getSetting('cssUITheme') || 'light'; //Set default to 'au params['imageDisplay'] = getSetting('imageDisplay') != null ? getSetting('imageDisplay') : true; //Set default to display images from Zim params['hideToolbars'] = getSetting('hideToolbars') != null ? getSetting('hideToolbars') : true; //Set default to true (hides both), 'top' (hides top only), or false (no hiding) params['rememberLastPage'] = getSetting('rememberLastPage') != null ? getSetting('rememberLastPage') : true; //Set default option to remember the last visited page between sessions -params['lastPageVisit'] = getSetting('lastPageVisit') || ''; params['useMathJax'] = getSetting('useMathJax') != null ? getSetting('useMathJax') : true; //Set default to true to display math formulae with MathJax, false to use fallback SVG images only //params['showFileSelectors'] = getCookie('showFileSelectors') != null ? getCookie('showFileSelectors') : false; //Set to true to display hidden file selectors in packaged apps params['showFileSelectors'] = true; //False will cause file selectors to be hidden on each load of the app (by ignoring cookie) @@ -86,8 +85,10 @@ params['allowInternetAccess'] = getSetting('allowInternetAccess'); //Do not touch these values unless you know what they do! Some are global variables, some are set programmatically params['imageDisplayMode'] = params.imageDisplay ? 'progressive' : 'manual'; -params['storedFile'] = getSetting('lastSelectedArchive') || params['packagedFile']; +params['storedFile'] = getSetting('lastSelectedArchive') || params['packagedFile'] || ''; params.storedFile = launchArguments ? launchArguments.files[0].name : params.storedFile; +params['lastPageVisit'] = params.rememberLastPage && params.storedFile ? getSetting(params.storedFile) || '' : ''; +params.lastPageVisit = params.lastPageVisit ? params.lastPageVisit + '@kiwixKey@' + params.storedFile : ''; params['storedFilePath'] = getSetting('lastSelectedArchivePath'); params.storedFilePath = params.storedFilePath ? decodeURIComponent(params.storedFilePath) : params.archivePath + '/' + params.packagedFile; params.storedFilePath = launchArguments ? launchArguments.files[0].path || '' : params.storedFilePath; @@ -146,7 +147,7 @@ if (/UWP/.test(params.appType) && params.contentInjectionMode === 'serviceworker //Prevent app boot loop with problematic pages that cause an app crash if (getSetting('lastPageLoad') === 'failed') { - params.lastPageVisit = ""; + params.lastPageVisit = ''; } else { //Cookie will signal failure until article is fully loaded if (params.storeType === 'cookie') {