diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-04-03 13:02:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-03 13:02:49 -0400 |
commit | a9fe2d03b22a0dd5760019f1325a7a86ebb07b85 (patch) | |
tree | aa2fe04c741c82c0456f44a39139c52988b6c22d /ext/js/pages/settings/collapsible-dictionary-controller.js | |
parent | 0d2d342cd373798e3daf42799a9f35d974db92f5 (diff) |
Update dictionary settings structure (#1587)
* Update dictionary settings structure to use an array instead of an object
* Update ensureDictionarySettings implementation
* Remove some usage of ObjectPropertyAccessor
Diffstat (limited to 'ext/js/pages/settings/collapsible-dictionary-controller.js')
-rw-r--r-- | ext/js/pages/settings/collapsible-dictionary-controller.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/js/pages/settings/collapsible-dictionary-controller.js b/ext/js/pages/settings/collapsible-dictionary-controller.js index 37793c6f..6eb3a9b4 100644 --- a/ext/js/pages/settings/collapsible-dictionary-controller.js +++ b/ext/js/pages/settings/collapsible-dictionary-controller.js @@ -15,10 +15,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -/* global - * ObjectPropertyAccessor - */ - class CollapsibleDictionaryController { constructor(settingsController) { this._settingsController = settingsController; @@ -65,12 +61,14 @@ class CollapsibleDictionaryController { this._setupAllSelect(fragment, options); - for (const dictionary of Object.keys(options.dictionaries)) { - const dictionaryInfo = this._dictionaryInfoMap.get(dictionary); + const {dictionaries} = options; + for (let i = 0, ii = dictionaries.length; i < ii; ++i) { + const {name} = dictionaries[i]; + const dictionaryInfo = this._dictionaryInfoMap.get(name); if (typeof dictionaryInfo === 'undefined') { continue; } - const select = this._addSelect(fragment, dictionary, `rev.${dictionaryInfo.revision}`); - select.dataset.setting = ObjectPropertyAccessor.getPathString(['dictionaries', dictionary, 'definitionsCollapsible']); + const select = this._addSelect(fragment, name, `rev.${dictionaryInfo.revision}`); + select.dataset.setting = `dictionaries[${i}].definitionsCollapsible`; this._eventListeners.addEventListener(select, 'settingChanged', this._onDefinitionsCollapsibleChange.bind(this), false); this._selects.push(select); @@ -125,7 +123,7 @@ class CollapsibleDictionaryController { _updateAllSelect(options) { let value = null; let varies = false; - for (const {definitionsCollapsible} of Object.values(options.dictionaries)) { + for (const {definitionsCollapsible} of options.dictionaries) { if (value === null) { value = definitionsCollapsible; } else if (value !== definitionsCollapsible) { @@ -140,8 +138,9 @@ class CollapsibleDictionaryController { async _setDefinitionsCollapsibleAll(value) { const options = await this._settingsController.getOptions(); const targets = []; - for (const dictionary of Object.keys(options.dictionaries)) { - const path = ObjectPropertyAccessor.getPathString(['dictionaries', dictionary, 'definitionsCollapsible']); + const {dictionaries} = options; + for (let i = 0, ii = dictionaries.length; i < ii; ++i) { + const path = `dictionaries[${i}].definitionsCollapsible`; targets.push({action: 'set', path, value}); } await this._settingsController.modifyProfileSettings(targets); |