diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-05-30 12:15:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-30 12:15:07 -0400 |
commit | efd35de67f6700ecf4f49a87d310d99cefbaa328 (patch) | |
tree | b031d5c24b3e118efb868bf1b098bb10cf3b2c3e /ext/js/display/display.js | |
parent | 0f0e80aadb97c95d307dcd97edabd2087d0a1743 (diff) |
Refactor display audio options (#1717)
* Update how options are updated and stored in DisplayAudio
* Add source list
* Improve menus for custom json
* Clear cache after options update
* Move function
* Update public API
* Simplify playing audio from a specific source
* Simplify audio list
* Refactor audio source usage
* Refactoring
* Refactor argument names
* Fix incorrect source usage
* Remove unused
* Remove return value
* Simplify details
* Simplify Anki card audio details
* Update the data that is passed to AudioDownloader
* Simplify schema handling
* Remove unnecessary details
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 1c4602c5..ccca8229 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -296,7 +296,6 @@ class Display extends EventDispatcher { this._updateDocumentOptions(options); this._updateTheme(options.general.popupTheme); this.setCustomCss(options.general.customPopupCss); - this._displayAudio.updateOptions(options); this._hotkeyHelpController.setOptions(options); this._displayGenerator.updateHotkeys(); this._hotkeyHelpController.setupNode(document.documentElement); @@ -1330,7 +1329,7 @@ class Display extends EventDispatcher { } async _playAudioCurrent() { - return await this._displayAudio.playAudio(this._index, 0); + await this._displayAudio.playAudio(this._index, 0); } _getEntry(index) { @@ -1552,26 +1551,17 @@ class Display extends EventDispatcher { } async _injectAnkiNoteMedia(dictionaryEntry, options, fields) { - const { - anki: {screenshot: {format, quality}}, - audio: {sources, customSourceUrl} - } = options; + const {anki: {screenshot: {format, quality}}} = options; const timestamp = Date.now(); const dictionaryEntryDetails = this._getDictionaryEntryDetailsForNote(dictionaryEntry); - let audioDetails = null; - if (dictionaryEntryDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio')) { - const primaryCardAudio = this._displayAudio.getPrimaryCardAudio(dictionaryEntryDetails.term, dictionaryEntryDetails.reading); - let preferredAudioIndex = null; - let sources2 = sources; - if (primaryCardAudio !== null) { - sources2 = [primaryCardAudio.source]; - preferredAudioIndex = primaryCardAudio.index; - } - audioDetails = {sources: sources2, preferredAudioIndex, customSourceUrl}; - } + const audioDetails = ( + dictionaryEntryDetails.type !== 'kanji' && AnkiUtil.fieldsObjectContainsMarker(fields, 'audio') ? + this._displayAudio.getAnkiNoteMediaAudioDetails(dictionaryEntryDetails.term, dictionaryEntryDetails.reading) : + null + ); const screenshotDetails = ( AnkiUtil.fieldsObjectContainsMarker(fields, 'screenshot') && typeof this._contentOriginTabId === 'number' ? @@ -1906,7 +1896,7 @@ class Display extends EventDispatcher { } _onHotkeyActionPlayAudioFromSource(source) { - this._displayAudio.playAudio(this._index, 0, [source]); + this._displayAudio.playAudio(this._index, 0, source); } _closeAllPopupMenus() { |