Skip to content

Commit

Permalink
Reset state upon load if showPreviousViewOnLoad
Browse files Browse the repository at this point in the history
And moved showPreviousViewOnLoad up to PDFViewerApplication.initialize
  • Loading branch information
Rob--W committed Feb 28, 2015
1 parent a544aed commit 1bead89
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ var PDFViewerApplication = {
}),
Preferences.get('useOnlyCssZoom').then(function resolved(value) {
PDFJS.useOnlyCssZoom = value;
}),
Preferences.get('showPreviousViewOnLoad').then(function (value) {
PDFViewerApplication.preferenceShowPreviousViewOnLoad = value;
if (!value && window.history.state) {
window.history.replaceState(null, '');
}
})

// TODO move more preferences and other async stuff here
]).catch(function (reason) { });

Expand Down Expand Up @@ -894,22 +901,18 @@ var PDFViewerApplication = {
});

// Fetch the necessary preference values.
var showPreviousViewOnLoad;
var showPreviousViewOnLoadPromise =
Preferences.get('showPreviousViewOnLoad').then(function (prefValue) {
showPreviousViewOnLoad = prefValue;
});
var defaultZoomValue;
var defaultZoomValuePromise =
Preferences.get('defaultZoomValue').then(function (prefValue) {
defaultZoomValue = prefValue;
});

var storePromise = store.initializedPromise;
Promise.all([firstPagePromise, storePromise, showPreviousViewOnLoadPromise,
defaultZoomValuePromise]).then(function resolved() {
Promise.all([firstPagePromise, storePromise, defaultZoomValuePromise]).then(
function resolved() {
var storedHash = null;
if (showPreviousViewOnLoad && store.get('exists', false)) {
if (PDFViewerApplication.preferenceShowPreviousViewOnLoad &&
store.get('exists', false)) {
var pageNum = store.get('page', '1');
var zoom = defaultZoomValue ||
store.get('zoom', self.pdfViewer.currentScale);
Expand Down

0 comments on commit 1bead89

Please sign in to comment.