aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-03-13 21:17:41 -0400
committerGitHub <noreply@github.com>2022-03-13 21:17:41 -0400
commitf98f5f939552d14b014396ce933bba4faa9607bb (patch)
tree0e90b172417301f15d99599d64ea7aa7e0336c72 /ext/js/background/backend.js
parent1590f5218c5872f3683820e9611d4a4fa2b7c341 (diff)
Improve Anki storeMediaFile (#2084)
* Use the return value of storeMediaFile * Update documentation
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index cb412db6..54e8ff08 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -1806,7 +1806,7 @@ class Backend {
if (extension === null) { extension = '.mp3'; }
let fileName = this._generateAnkiNoteMediaFileName('yomichan_audio', extension, timestamp, definitionDetails);
fileName = fileName.replace(/\]/g, '');
- await ankiConnect.storeMediaFile(fileName, data);
+ fileName = await ankiConnect.storeMediaFile(fileName, data);
return fileName;
}
@@ -1821,8 +1821,8 @@ class Backend {
throw new Error('Unknown media type for screenshot image');
}
- const fileName = this._generateAnkiNoteMediaFileName('yomichan_browser_screenshot', extension, timestamp, definitionDetails);
- await ankiConnect.storeMediaFile(fileName, data);
+ let fileName = this._generateAnkiNoteMediaFileName('yomichan_browser_screenshot', extension, timestamp, definitionDetails);
+ fileName = await ankiConnect.storeMediaFile(fileName, data);
return fileName;
}
@@ -1839,8 +1839,8 @@ class Backend {
throw new Error('Unknown media type for clipboard image');
}
- const fileName = this._generateAnkiNoteMediaFileName('yomichan_clipboard_image', extension, timestamp, definitionDetails);
- await ankiConnect.storeMediaFile(fileName, data);
+ let fileName = this._generateAnkiNoteMediaFileName('yomichan_clipboard_image', extension, timestamp, definitionDetails);
+ fileName = await ankiConnect.storeMediaFile(fileName, data);
return fileName;
}
@@ -1877,7 +1877,7 @@ class Backend {
const extension = MediaUtil.getFileExtensionFromImageMediaType(mediaType);
fileName = this._generateAnkiNoteMediaFileName(`yomichan_dictionary_media_${i + 1}`, extension, timestamp, definitionDetails);
try {
- await ankiConnect.storeMediaFile(fileName, content);
+ fileName = await ankiConnect.storeMediaFile(fileName, content);
} catch (e) {
errors.push(e);
fileName = null;