From d66a5e3b87912f7df0ac4b6dc1c2d2d127702d4f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 15 Nov 2020 14:14:52 -0500 Subject: Fix settings resetting not initializing dictionary settings properly (#1036) --- ext/bg/js/settings/backup-controller.js | 9 +++++++++ ext/bg/js/settings/dictionary-controller.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ext/bg/js/settings/backup-controller.js b/ext/bg/js/settings/backup-controller.js index d5fa28bc..8f24bdb4 100644 --- a/ext/bg/js/settings/backup-controller.js +++ b/ext/bg/js/settings/backup-controller.js @@ -16,6 +16,7 @@ */ /* global + * DictionaryController * Modal * OptionsUtil * api @@ -383,6 +384,14 @@ class BackupController { // Get default options const optionsFull = this._optionsUtil.getDefault(); + // Update dictionaries + const dictionaries = await this._settingsController.getDictionaryInfo(); + for (const {options: {dictionaries: optionsDictionaries}} of optionsFull.profiles) { + for (const {title} of dictionaries) { + optionsDictionaries[title] = DictionaryController.createDefaultDictionarySettings(); + } + } + // Assign options try { await this._settingsImportSetOptionsFull(optionsFull); diff --git a/ext/bg/js/settings/dictionary-controller.js b/ext/bg/js/settings/dictionary-controller.js index 6c7e00b7..db3ebb22 100644 --- a/ext/bg/js/settings/dictionary-controller.js +++ b/ext/bg/js/settings/dictionary-controller.js @@ -489,11 +489,7 @@ class DictionaryController { targets.push({ action: 'set', path, - value: { - enabled: false, - allowSecondarySearches: false, - priority: 0 - } + value: DictionaryController.createDefaultDictionarySettings() }); } } @@ -502,4 +498,12 @@ class DictionaryController { await this._settingsController.modifyGlobalSettings(targets); } } + + static createDefaultDictionarySettings() { + return { + enabled: false, + allowSecondarySearches: false, + priority: 0 + }; + } } -- cgit v1.2.3