From 700d75cacd7fee23410dcaf13531ebc2b151d56a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 15 Apr 2022 20:29:45 -0300 Subject: inherit coverArtFileExtension more carefully --- src/data/things.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/data/things.js b/src/data/things.js index 6ed0aa47..4cc5d061 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -630,6 +630,15 @@ Track.findAlbum = (track, albumData) => { return albumData?.find(album => album.tracks.includes(track)); }; +// Another reused utility function. This one's logic is a bit more complicated. +Track.hasCoverArt = (track, albumData, coverArtistContribsByRef, hasCoverArt) => { + return ( + hasCoverArt ?? + (coverArtistContribsByRef?.length > 0 || null) ?? + Track.findAlbum(track, albumData)?.hasTrackArt ?? + true); +}; + Track.propertyDescriptors = { // Update & expose @@ -661,10 +670,7 @@ Track.propertyDescriptors = { expose: { dependencies: ['albumData', 'coverArtistContribsByRef'], transform: (hasCoverArt, { albumData, coverArtistContribsByRef, [Track.instance]: track }) => ( - hasCoverArt ?? - (coverArtistContribsByRef?.length > 0 || null) ?? - Track.findAlbum(track, albumData)?.hasTrackArt ?? - true) + Track.hasCoverArt(track, albumData, coverArtistContribsByRef, hasCoverArt)) } }, @@ -674,11 +680,13 @@ Track.propertyDescriptors = { update: {validate: isFileExtension}, expose: { - dependencies: ['albumData'], - transform: (coverArtFileExtension, { albumData, [Track.instance]: track }) => ( + dependencies: ['albumData', 'coverArtistContribsByRef'], + transform: (coverArtFileExtension, { albumData, coverArtistContribsByRef, hasCoverArt, [Track.instance]: track }) => ( coverArtFileExtension ?? - Track.findAlbum(track, albumData)?.trackCoverArtFileExtension ?? - true) + (Track.hasCoverArt(track, albumData, coverArtistContribsByRef, hasCoverArt) + ? Track.findAlbum(track, albumData)?.trackCoverArtFileExtension + : Track.findAlbum(track, albumData)?.coverArtFileExtension) ?? + 'jpg') } }, -- cgit 1.3.0-6-gf8a5