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) {
|
async function apiAudioGetUrl(definition, source, optionsContext) {
|
||||||
return audioBuildUrl(definition, source, optionsContext);
|
return audioGetUrl(definition, source, optionsContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function apiInjectScreenshot(definition, fields, screenshot) {
|
async function apiInjectScreenshot(definition, fields, screenshot) {
|
||||||
|
@ -93,20 +93,14 @@ const audioUrlBuilders = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function audioBuildUrl(definition, mode, optionsContext, cache={}) {
|
async function audioGetUrl(definition, mode, optionsContext, download) {
|
||||||
const cacheKey = `${mode}:${definition.expression}`;
|
|
||||||
if (cache.hasOwnProperty(cacheKey)) {
|
|
||||||
return Promise.resolve(cache[cacheKey]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (audioUrlBuilders.hasOwnProperty(mode)) {
|
if (audioUrlBuilders.hasOwnProperty(mode)) {
|
||||||
const handler = audioUrlBuilders[mode];
|
const handler = audioUrlBuilders[mode];
|
||||||
return handler(definition, optionsContext).then(
|
try {
|
||||||
(url) => {
|
return await handler(definition, optionsContext, download);
|
||||||
cache[cacheKey] = url;
|
} catch (e) {
|
||||||
return url;
|
// NOP
|
||||||
},
|
}
|
||||||
() => null);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user