From ba288277a5e73026f7b0c07d993aa00a5e66c332 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 14 May 2024 12:59:44 -0400 Subject: Update anki settings when Configure Anki card format button is clicked instead of requiring page refresh (#934) * Update anki settings when Configure Anki card format is clicked instead of requiring page refresh * Select by data-modal-action instead of id --- ext/js/pages/settings/anki-controller.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ext/js/pages/settings') diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 7eb09c85..2d461336 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -582,6 +582,17 @@ class AnkiCardController { this._ankiCardFieldsContainer = this._node.querySelector('.anki-card-fields'); + /** @type {HTMLTextAreaElement} */ + const mainSettingsEntry = querySelectorNotNull(document, '[data-modal-action="show,anki-cards"]'); + mainSettingsEntry.addEventListener('click', (() => { + const updatedCardOptions = this._getCardOptions(ankiOptions, this._optionsType); + if (updatedCardOptions === null) { return; } + this._deckController.prepare(deckControllerSelect, updatedCardOptions.deck); + this._modelController.prepare(modelControllerSelect, updatedCardOptions.model); + this._fields = updatedCardOptions.fields; + void this.updateAnkiState(); + }).bind(this), false); + this._setupFields(); this._eventListeners.addEventListener(this._deckController.select, 'change', this._onCardDeckChange.bind(this), false); -- cgit v1.2.3