From 5bbbbf152e91b7bc57f420421bc77529f24f4e03 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 26 Jun 2018 14:07:56 +0200 Subject: [PATCH] Stop storing/using the 'exists' property of `ViewHistory` database entries Rather than using a "special" property to check if a `ViewHistory` database entry existed on load, it seems that you could just as well check for the existence of one of the actually needed properties instead (here 'page' is used). This way we can avoid storing what, more of less, amounts to useless state, which will help reduce the size of the `ViewHistory` database. Given that we don't directly, nor need to, validate the `ViewHistory` data but rely on other parts of the code-base to do so, the existance of an 'exists' property doesn't in and of itself really add much utility. Finally, to simplify the implementation the 'exists' property won't be actively removed from the `ViewHistory` data. Instead we'll simply stop adding 'exists' when writing `ViewHistory` data, and rely on the existing pruning of old entries to eventually remove any remnants of 'exists' from storage. --- web/app.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index f0e33d4f5..f87d52c4f 100644 --- a/web/app.js +++ b/web/app.js @@ -1016,8 +1016,7 @@ let PDFViewerApplication = { hash: null, }; let storePromise = store.getMultiple({ - exists: false, - page: '1', + page: null, zoom: DEFAULT_SCALE_VALUE, scrollLeft: '0', scrollTop: '0', @@ -1037,7 +1036,7 @@ let PDFViewerApplication = { let scrollMode = AppOptions.get('scrollModeOnLoad'); let spreadMode = AppOptions.get('spreadModeOnLoad'); - if (values.exists && AppOptions.get('showPreviousViewOnLoad')) { + if (values.page && AppOptions.get('showPreviousViewOnLoad')) { hash = 'page=' + values.page + '&zoom=' + (AppOptions.get('defaultZoomValue') || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop; @@ -1852,7 +1851,6 @@ function webViewerUpdateViewarea(evt) { if (store && PDFViewerApplication.isInitialViewSet) { store.setMultiple({ - 'exists': true, 'page': location.pageNumber, 'zoom': location.scale, 'scrollLeft': location.left,