aboutsummaryrefslogtreecommitdiff
path: root/ext/js/media/media-loader.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-14 22:51:20 -0400
committerGitHub <noreply@github.com>2021-03-14 22:51:20 -0400
commita52d86a39e9cca620823e3d97d7c129a7abafced (patch)
tree1e75aef621f21a96a21bdff14ad2e48056ec56d2 /ext/js/media/media-loader.js
parent07df1e011794f5a77f7fb7da5cd9ea353a8747e2 (diff)
Dictionary database improvements (#1527)
* Update formatting * Add _findMultiBulk * Update implementation of findTermsBySequenceBulk * Update tests * Generalize query creation * Remove _findGenericBulk * Reduce function creation * Add more bindings * Simplify findTermsExactBulk implementation * Update var names * Update _findMultiBulk to support multiple index queries * Update findTermsBulk * Update getMedia implementation * Pass data arg to getAll and findFirst to avoid having multiple closures
Diffstat (limited to 'ext/js/media/media-loader.js')
-rw-r--r--ext/js/media/media-loader.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/js/media/media-loader.js b/ext/js/media/media-loader.js
index 4ac733c5..7dafc2a3 100644
--- a/ext/js/media/media-loader.js
+++ b/ext/js/media/media-loader.js
@@ -26,13 +26,13 @@ class MediaLoader {
this._loadMediaData = [];
}
- async loadMedia(path, dictionaryName, onLoad, onUnload) {
+ async loadMedia(path, dictionary, onLoad, onUnload) {
const token = this._token;
const data = {onUnload, loaded: false};
this._loadMediaData.push(data);
- const media = await this.getMedia(path, dictionaryName);
+ const media = await this.getMedia(path, dictionary);
if (token !== this._token) { return; }
onLoad(media.url);
@@ -59,14 +59,14 @@ class MediaLoader {
this._token = {};
}
- async getMedia(path, dictionaryName) {
+ async getMedia(path, dictionary) {
let cachedData;
- let dictionaryCache = this._mediaCache.get(dictionaryName);
+ let dictionaryCache = this._mediaCache.get(dictionary);
if (typeof dictionaryCache !== 'undefined') {
cachedData = dictionaryCache.get(path);
} else {
dictionaryCache = new Map();
- this._mediaCache.set(dictionaryName, dictionaryCache);
+ this._mediaCache.set(dictionary, dictionaryCache);
}
if (typeof cachedData === 'undefined') {
@@ -76,15 +76,15 @@ class MediaLoader {
url: null
};
dictionaryCache.set(path, cachedData);
- cachedData.promise = this._getMediaData(path, dictionaryName, cachedData);
+ cachedData.promise = this._getMediaData(path, dictionary, cachedData);
}
return cachedData.promise;
}
- async _getMediaData(path, dictionaryName, cachedData) {
+ async _getMediaData(path, dictionary, cachedData) {
const token = this._token;
- const data = (await yomichan.api.getMedia([{path, dictionaryName}]))[0];
+ const data = (await yomichan.api.getMedia([{path, dictionary}]))[0];
if (token === this._token && data !== null) {
const blob = MediaUtil.createBlobFromBase64Content(data.content, data.mediaType);
const url = URL.createObjectURL(blob);