diff --git a/web/app.js b/web/app.js index 67d071f4c..933d9eba7 100644 --- a/web/app.js +++ b/web/app.js @@ -635,8 +635,6 @@ let PDFViewerApplication = { if (this.pdfLoadingTask) { // We need to destroy already opened document. return this.close().then(() => { - // Reload the preferences if a document was previously opened. - this.preferences.reload(); // ... and repeat the open() call. return this.open(file, args); }); diff --git a/web/preferences.js b/web/preferences.js index fb535cad6..a5fa67388 100644 --- a/web/preferences.js +++ b/web/preferences.js @@ -60,9 +60,19 @@ class BasePreferences { this.prefs = Object.assign(Object.create(null), defaults); return this._readFromStorage(defaults); - }).then((prefObj) => { - if (prefObj) { - this.prefs = prefObj; + }).then((prefs) => { + if (!prefs) { + return; + } + for (let name in prefs) { + const defaultValue = this.defaults[name], prefValue = prefs[name]; + // Ignore preferences not present in, or whose types don't match, + // the default values. + if (defaultValue === undefined || + typeof prefValue !== typeof defaultValue) { + continue; + } + this.prefs[name] = prefValue; } }); } @@ -99,21 +109,6 @@ class BasePreferences { }); } - /** - * Replace the current preference values with the ones from storage. - * @return {Promise} A promise that is resolved when the preference values - * have been updated. - */ - reload() { - return this._initializedPromise.then(() => { - return this._readFromStorage(this.defaults); - }).then((prefObj) => { - if (prefObj) { - this.prefs = prefObj; - } - }); - } - /** * Set the value of a preference. * @param {string} name The name of the preference that should be changed.