summaryrefslogtreecommitdiff
path: root/ext/js/data
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-08-20 11:17:24 -0400
committerGitHub <noreply@github.com>2022-08-20 11:17:24 -0400
commit310303ca1a123a77f9bd116af4dc64ad9c3256c5 (patch)
treeaf8bad0ec544625970a5f2a4613fff27773b162c /ext/js/data
parent02483a45b1b7fb0654b3f37571b92400b76734a5 (diff)
Audio download timeout (#2187)
* Add support for an idle timeout when downloading audio * Update eslint rules * Pass idleTimeout to the downloader from DisplayAnki * Add anki.downloadTimeout setting * Update tests * Assign _audioDownloadIdleTimeout using settings * Show info about cancelled downloads * Handle Firefox bug * Improve audio errors * Refactor * Move functions to RequestBuilder
Diffstat (limited to 'ext/js/data')
-rw-r--r--ext/js/data/anki-note-builder.js4
-rw-r--r--ext/js/data/options-util.js12
2 files changed, 13 insertions, 3 deletions
diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js
index 53cc29f6..9691aadb 100644
--- a/ext/js/data/anki-note-builder.js
+++ b/ext/js/data/anki-note-builder.js
@@ -320,8 +320,8 @@ class AnkiNoteBuilder {
if (injectAudio && dictionaryEntryDetails.type !== 'kanji') {
const audioOptions = mediaOptions.audio;
if (typeof audioOptions === 'object' && audioOptions !== null) {
- const {sources, preferredAudioIndex} = audioOptions;
- audioDetails = {sources, preferredAudioIndex};
+ const {sources, preferredAudioIndex, idleTimeout} = audioOptions;
+ audioDetails = {sources, preferredAudioIndex, idleTimeout};
}
}
if (injectScreenshot) {
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index a163580f..8c50493a 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -468,7 +468,8 @@ class OptionsUtil {
{async: false, update: this._updateVersion16.bind(this)},
{async: false, update: this._updateVersion17.bind(this)},
{async: false, update: this._updateVersion18.bind(this)},
- {async: false, update: this._updateVersion19.bind(this)}
+ {async: false, update: this._updateVersion19.bind(this)},
+ {async: false, update: this._updateVersion20.bind(this)}
];
if (typeof targetVersion === 'number' && targetVersion < result.length) {
result.splice(targetVersion);
@@ -975,4 +976,13 @@ class OptionsUtil {
}
return options;
}
+
+ _updateVersion20(options) {
+ // Version 20 changes:
+ // Added anki.downloadTimeout.
+ for (const profile of options.profiles) {
+ profile.options.anki.downloadTimeout = 0;
+ }
+ return options;
+ }
}