diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index e2fcf1e32..662de87a5 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -494,6 +494,8 @@ export class DictionaryController { this._settingsController = settingsController; /** @type {import('./modal-controller.js').ModalController} */ this._modalController = modalController; + /** @type {HTMLElement} */ + this._dictionaryModalBody = querySelectorNotNull(document, '#dictionaries-modal-body'); /** @type {import('./status-footer.js').StatusFooter} */ this._statusFooter = statusFooter; /** @type {?import('dictionary-importer').Summary[]} */ @@ -643,7 +645,7 @@ export class DictionaryController { const event = {source: this}; this._settingsController.trigger('dictionarySettingsReordered', event); - await this._updateEntries(); + this._updateCurrentEntries(options); } /** @@ -822,6 +824,28 @@ export class DictionaryController { } } + /** + * @param {import('settings').ProfileOptions} options + */ + _updateCurrentEntries(options) { + const dictionariesModalBodyScrollY = this._dictionaryModalBody.scrollTop; + const dictionaries = this._dictionaries; + if (dictionaries === null) { return; } + + this._dictionaryEntries.map((dictionaryEntry) => dictionaryEntry.cleanup()); + + const dictionaryOptionsArray = options.dictionaries; + for (let i = 0; i < dictionaryOptionsArray.length; i++) { + const {name} = dictionaryOptionsArray[i]; + /** @type {import('dictionary-importer').Summary | undefined} */ + const dictionaryInfo = dictionaries.find((dictionary) => dictionary.title === name); + if (typeof dictionaryInfo === 'undefined') { continue; } + const updateDownloadUrl = dictionaryInfo.downloadUrl ?? null; + this._createDictionaryEntry(i, dictionaryInfo, updateDownloadUrl); + } + this._dictionaryModalBody.scroll({top: dictionariesModalBodyScrollY}); + } + /** * @param {import('settings').ProfileOptions} options */ diff --git a/ext/templates-modals.html b/ext/templates-modals.html index e7c00e55b..48c599551 100644 --- a/ext/templates-modals.html +++ b/ext/templates-modals.html @@ -11,7 +11,7 @@ -