aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-14 19:38:50 -0400
committerGitHub <noreply@github.com>2020-10-14 19:38:50 -0400
commite6a1bcc0f58a4e9271149ec75d77f4072f357989 (patch)
tree98e0a0ffe2ee746067e7c1a9fd07383968488885 /ext/bg/js
parent51904761cefe4d93a97ebf3c0c5bf127db2cbc69 (diff)
Ensure settings exist for all installed dictionaries (#922)
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/settings/dictionary-controller.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js
index 3db16979..2ff12ab9 100644
--- a/ext/bg/js/settings/dictionary-controller.js
+++ b/ext/bg/js/settings/dictionary-controller.js
@@ -196,6 +196,7 @@ class DictionaryController {
}
this._dictionaryEntries = [];
+ await this._ensureDictionarySettings(dictionaries);
for (const dictionary of dictionaries) {
this._createDictionaryEntry(dictionary);
}
@@ -393,4 +394,32 @@ class DictionaryController {
}
await this._settingsController.modifyGlobalSettings(targets);
}
+
+ async _ensureDictionarySettings(dictionaries2) {
+ const optionsFull = await this._settingsController.getOptionsFull();
+ const {profiles} = optionsFull;
+ const targets = [];
+ for (const {title} of dictionaries2) {
+ for (let i = 0, ii = profiles.length; i < ii; ++i) {
+ const {options: {dictionaries: dictionaryOptions}} = profiles[i];
+ if (Object.prototype.hasOwnProperty.call(dictionaryOptions, title)) { continue; }
+
+ const path = ObjectPropertyAccessor.getPathString(['profiles', i, 'options', 'dictionaries', title]);
+ targets.push({
+ action: 'set',
+ path,
+ value: {
+ enabled: false,
+ allowSecondarySearches: false,
+ priority: 0
+ }
+ });
+ }
+ }
+
+ if (targets.length > 0) {
+ const r = await this._settingsController.modifyGlobalSettings(targets);
+ console.log(r);
+ }
+ }
}