Skip to content

Commit

Permalink
Update anki settings when Configure Anki card format button is clicke…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
Kuuuube authored May 14, 2024
1 parent d60b010 commit ba28827
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ext/js/pages/settings/anki-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ba28827

Please sign in to comment.