diff options
Diffstat (limited to 'ext/js/display')
-rw-r--r-- | ext/js/display/display-anki.js | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 12133ad0..e2101481 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -48,6 +48,7 @@ class DisplayAnki { this._screenshotQuality = 100; this._scanLength = 10; this._noteGuiMode = 'browse'; + this._audioDownloadIdleTimeout = null; this._noteTags = []; this._modeOptions = new Map(); this._dictionaryEntryTypeModeMap = new Map([ @@ -133,7 +134,19 @@ class DisplayAnki { _onOptionsUpdated({options}) { const { general: {resultOutputMode, glossaryLayoutMode, compactTags}, - anki: {tags, duplicateScope, duplicateScopeCheckAllModels, suspendNewCards, checkForDuplicates, displayTags, kanji, terms, noteGuiMode, screenshot: {format, quality}}, + anki: { + tags, + duplicateScope, + duplicateScopeCheckAllModels, + suspendNewCards, + checkForDuplicates, + displayTags, + kanji, + terms, + noteGuiMode, + screenshot: {format, quality}, + downloadTimeout + }, scanning: {length: scanLength} } = options; @@ -150,6 +163,7 @@ class DisplayAnki { this._scanLength = scanLength; this._noteGuiMode = noteGuiMode; this._noteTags = [...tags]; + this._audioDownloadIdleTimeout = (Number.isFinite(downloadTimeout) && downloadTimeout > 0 ? downloadTimeout : null); this._modeOptions.clear(); this._modeOptions.set('kanji', kanji); this._modeOptions.set('term-kanji', terms); @@ -536,7 +550,7 @@ class DisplayAnki { const fields = Object.entries(modeOptions.fields); const contentOrigin = this._display.getContentOrigin(); const details = this._ankiNoteBuilder.getDictionaryEntryDetailsForNote(dictionaryEntry); - const audioDetails = (details.type === 'term' ? this._displayAudio.getAnkiNoteMediaAudioDetails(details.term, details.reading) : null); + const audioDetails = this._getAnkiNoteMediaAudioDetails(details); const optionsContext = this._display.getOptionsContext(); const {note, errors, requirements: outputRequirements} = await this._ankiNoteBuilder.createNote({ @@ -586,6 +600,12 @@ class DisplayAnki { return {text, offset}; } + _getAnkiNoteMediaAudioDetails(details) { + if (details.type !== 'term') { return null; } + const {sources, preferredAudioIndex} = this._displayAudio.getAnkiNoteMediaAudioDetails(details.term, details.reading); + return {sources, preferredAudioIndex, idleTimeout: this._audioDownloadIdleTimeout}; + } + // View note functions _onViewNoteButtonClick(e) { |