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.
This commit is contained in:
Jonas Jenwald 2018-06-26 14:07:56 +02:00
parent 253aae15fc
commit 5bbbbf152e

View File

@ -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,