aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-12 23:09:58 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 12:20:56 -0400
commit69b28571bdf8fb4c13198223e8a5668cf490840c (patch)
tree05fa8f0f0ba9f593ee746411e0a9e2c9a83ddd45 /ext/bg
parent54d4c65854289de9d454198d7575d3db824cf0f1 (diff)
audioBuildUrl => audioGetUrl and simplify
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/api.js2
-rw-r--r--ext/bg/js/audio.js18
2 files changed, 7 insertions, 13 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 94a70c34..9fefadca 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -176,7 +176,7 @@ apiCommandExec.handlers = {
};
async function apiAudioGetUrl(definition, source, optionsContext) {
- return audioBuildUrl(definition, source, optionsContext);
+ return audioGetUrl(definition, source, optionsContext);
}
async function apiInjectScreenshot(definition, fields, screenshot) {
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index 1a626d42..9508abf0 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -93,20 +93,14 @@ const audioUrlBuilders = {
}
};
-async function audioBuildUrl(definition, mode, optionsContext, cache={}) {
- const cacheKey = `${mode}:${definition.expression}`;
- if (cache.hasOwnProperty(cacheKey)) {
- return Promise.resolve(cache[cacheKey]);
- }
-
+async function audioGetUrl(definition, mode, optionsContext, download) {
if (audioUrlBuilders.hasOwnProperty(mode)) {
const handler = audioUrlBuilders[mode];
- return handler(definition, optionsContext).then(
- (url) => {
- cache[cacheKey] = url;
- return url;
- },
- () => null);
+ try {
+ return await handler(definition, optionsContext, download);
+ } catch (e) {
+ // NOP
+ }
}
return null;
}