summaryrefslogtreecommitdiff
path: root/ext/js/language/dictionary-worker.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-09-03 22:33:58 -0400
committerGitHub <noreply@github.com>2021-09-03 22:33:58 -0400
commit0331374241a55415cbae37d386f47da428ede3db (patch)
tree535801cfabec21a81d2a9ee57b14ef1b8f7678ed /ext/js/language/dictionary-worker.js
parent764d59df137dacfa6b4cfa8394b711fda904efd9 (diff)
Dictionary media import improvements (#1926)
* Add base64ToArrayBuffer to StringUtil * Remove unnecessary media-util.js import * Run async requirements in serial rather than parallel * Update API.getMedia handler to convert ArrayBuffer content to base64 * Rename getImageResolution to getImageDetails * Change parameter order of getImageDetails * Pre-process and store media as an ArrayBuffer * Remove MediaUtil.createBlobFromBase64Content * Fix Anki media injection
Diffstat (limited to 'ext/js/language/dictionary-worker.js')
-rw-r--r--ext/js/language/dictionary-worker.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/js/language/dictionary-worker.js b/ext/js/language/dictionary-worker.js
index 92faa3dc..be94c397 100644
--- a/ext/js/language/dictionary-worker.js
+++ b/ext/js/language/dictionary-worker.js
@@ -85,8 +85,8 @@ class DictionaryWorker {
case 'progress':
this._onMessageProgress(params, details.onProgress);
break;
- case 'getImageResolution':
- this._onMessageGetImageResolution(params, details.worker);
+ case 'getImageDetails':
+ this._onMessageGetImageDetails(params, details.worker);
break;
}
}
@@ -115,16 +115,17 @@ class DictionaryWorker {
onProgress(...args);
}
- async _onMessageGetImageResolution(params, worker) {
- const {id, mediaType, content} = params;
+ async _onMessageGetImageDetails(params, worker) {
+ const {id, content, mediaType} = params;
+ const transfer = [];
let response;
try {
- const result = await this._dictionaryImporterMediaLoader.getImageResolution(mediaType, content);
+ const result = await this._dictionaryImporterMediaLoader.getImageDetails(content, mediaType, transfer);
response = {id, result};
} catch (e) {
response = {id, error: serializeError(e)};
}
- worker.postMessage({action: 'getImageResolution.response', params: response});
+ worker.postMessage({action: 'getImageDetails.response', params: response}, transfer);
}
_formatimportDictionaryResult(result) {