diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-08 13:27:32 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-09-15 15:58:19 -0400 |
commit | c002e1bbd21341ae758819da59b7b65b99b97f4f (patch) | |
tree | 7281f8098807d134031174679d753d7dceabc9c9 /ext/bg/js | |
parent | 6c571bf8284c44bf01fe20c267fe72cce235b90d (diff) |
Update dictionaries for all profile options
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/settings.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js index b6434843..cb3ddd4e 100644 --- a/ext/bg/js/settings.js +++ b/ext/bg/js/settings.js @@ -16,6 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +async function getOptionsArray() { + const optionsFull = await apiOptionsGetFull(); + return optionsFull.profiles.map(profile => profile.options); +} + async function formRead(options) { options.general.enable = $('#enable').prop('checked'); options.general.showGuide = $('#show-usage-guide').prop('checked'); @@ -415,12 +420,14 @@ async function onDictionaryPurge(e) { dictionarySpinnerShow(true); await utilDatabasePurge(); - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - options.dictionaries = utilBackgroundIsolate({}); - options.general.mainDictionary = ''; + for (const options of await getOptionsArray()) { + options.dictionaries = utilBackgroundIsolate({}); + options.general.mainDictionary = ''; + } await settingsSaveOptions(); + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); await dictionaryGroupsPopulate(options); await formMainDictionaryOptionsPopulate(options); } catch (e) { @@ -457,24 +464,25 @@ async function onDictionaryImport(e) { const exceptions = []; const summary = await utilDatabaseImport(e.target.files[0], updateProgress, exceptions); - const optionsContext = getOptionsContext(); - const options = await apiOptionsGet(optionsContext); - options.dictionaries[summary.title] = utilBackgroundIsolate({ - enabled: true, - priority: 0, - allowSecondarySearches: false - }); - if (summary.sequenced && options.general.mainDictionary === '') { - options.general.mainDictionary = summary.title; + for (const options of await getOptionsArray()) { + options.dictionaries[summary.title] = utilBackgroundIsolate({ + enabled: true, + priority: 0, + allowSecondarySearches: false + }); + if (summary.sequenced && options.general.mainDictionary === '') { + options.general.mainDictionary = summary.title; + } } + await settingsSaveOptions(); if (exceptions.length > 0) { exceptions.push(`Dictionary may not have been imported properly: ${exceptions.length} error${exceptions.length === 1 ? '' : 's'} reported.`); dictionaryErrorsShow(exceptions); } - await settingsSaveOptions(); - + const optionsContext = getOptionsContext(); + const options = await apiOptionsGet(optionsContext); await dictionaryGroupsPopulate(options); await formMainDictionaryOptionsPopulate(options); } catch (e) { |