audioBuildUrl => audioGetUrl and simplify
This commit is contained in:
parent
54d4c65854
commit
69b28571bd
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user