Merge pull request #12636 from Snuffleupagus/AppOptions-setAll

Add an `AppOptions.setAll` method, and use it in `PDFViewerApplication._readPreferences`
This commit is contained in:
Tim van der Meij 2020-11-18 21:16:09 +01:00 committed by GitHub
commit d3936ac9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -305,12 +305,9 @@ const PDFViewerApplication = {
return;
}
try {
const prefs = await this.preferences.getAll();
for (const name in prefs) {
AppOptions.set(name, prefs[name]);
}
AppOptions.setAll(await this.preferences.getAll());
} catch (reason) {
console.error(`_readPreferences: "${reason.message}".`);
console.error(`_readPreferences: "${reason?.message}".`);
}
},
@ -385,6 +382,9 @@ const PDFViewerApplication = {
AppOptions.set("locale", hashParams.locale);
}
if (waitOn.length === 0) {
return undefined;
}
return Promise.all(waitOn).catch(reason => {
console.error(`_parseHashParameters: "${reason.message}".`);
});

View File

@ -314,6 +314,12 @@ class AppOptions {
userOptions[name] = value;
}
static setAll(options) {
for (const name in options) {
userOptions[name] = options[name];
}
}
static remove(name) {
delete userOptions[name];
}