From f974ac3fd8c3a07a57a0db434ac35111c9f0991f Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Tue, 18 Jan 2022 14:41:46 -0500 Subject: [PATCH] Do not automatically include the preview URL into the list of download formats (#627) --- .../VAudioTrack/layouts/VFullLayout.vue | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/VAudioTrack/layouts/VFullLayout.vue b/src/components/VAudioTrack/layouts/VFullLayout.vue index 3714c83bbf..410d400970 100644 --- a/src/components/VAudioTrack/layouts/VFullLayout.vue +++ b/src/components/VAudioTrack/layouts/VFullLayout.vue @@ -89,25 +89,27 @@ export default defineComponent({ /** * Creates a list of { extension_name, download_url } objects - * for DownloadButton + * for DownloadButton. + * + * If there are `alt_files` then just use that list. Otherwise, + * create one using the preview URL. + * * @param {AudioDetail} audio */ const getFormats = (audio) => { - let formats = [ + if (audio.alt_files?.length) { + return audio.alt_files.map((altFile) => ({ + extension_name: displayFormat(audio.provider, altFile.filetype), + download_url: altFile.url, + })) + } + + return [ { extension_name: displayFormat(audio.provider, audio.filetype), download_url: audio.url, }, ] - if (audio.alt_files) { - formats = formats.concat( - audio.alt_files.map((altFile) => ({ - extension_name: displayFormat(audio.provider, altFile.filetype), - download_url: altFile.url, - })) - ) - } - return formats } const isSmall = computed(() => props.size === 's')