aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-06 23:00:00 -0400
committerGitHub <noreply@github.com>2020-10-06 23:00:00 -0400
commit1a91935dd75c59951369cdb7f48950124ad9bdee (patch)
tree0e3422b5f1a1bbb5a8319e91607a95de47a1fcad
parent2f96218e33cf5b7e2077a802a42e5a8fb489e26f (diff)
Fix dictionary settings not being deleted when deleting a single dictionary (#893)
-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);
+ }
}