aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-06 23:00:00 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-14 19:42:43 -0400
commit5395f2f629f6410e42cc2f74b0e165141b911121 (patch)
treec281c69d934d454c2d3a4d09f5bf27c22bb37d26 /ext/bg
parent50f2385aaffc39507402ad8260cb49501763d7dc (diff)
Fix dictionary settings not being deleted when deleting a single dictionary (#893)
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/settings/dictionary-controller.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js
index e5a07f9d..7a71a02a 100644
--- a/ext/bg/js/settings/dictionary-controller.js
+++ b/ext/bg/js/settings/dictionary-controller.js
@@ -351,6 +351,7 @@ class DictionaryController {
};
await this._deleteDictionaryInternal(dictionaryTitle, onProgress);
+ await this._deleteDictionarySettings(dictionaryTitle);
} catch (e) {
yomichan.logError(e);
} finally {
@@ -389,4 +390,18 @@ class DictionaryController {
await dictionaryDatabase.prepare();
return dictionaryDatabase;
}
+
+ async _deleteDictionarySettings(dictionaryTitle) {
+ const optionsFull = await this._settingsController.getOptionsFull();
+ const {profiles} = optionsFull;
+ const targets = [];
+ for (let i = 0, ii = profiles.length; i < ii; ++i) {
+ const {options: {dictionaries}} = profiles[i];
+ if (Object.prototype.hasOwnProperty.call(dictionaries, dictionaryTitle)) {
+ const path = ObjectPropertyAccessor.getPathString(['profiles', i, 'options', 'dictionaries', dictionaryTitle]);
+ targets.push({action: 'delete', path});
+ }
+ }
+ await this._settingsController.modifyGlobalSettings(targets);
+ }
}