From 04589995da7ceae84aec112e44f7451e9bc47e0c Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 25 Nov 2025 14:46:53 -0400 Subject: data: Track: chop withHasUniqueCoverArt --- src/data/things/track.js | 99 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 5 deletions(-) (limited to 'src/data/things') diff --git a/src/data/things/track.js b/src/data/things/track.js index ff27e665..3c72468a 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -30,8 +30,6 @@ import { parseLyrics, } from '#yaml'; -import {withPropertyFromList, withPropertyFromObject} from '#composite/data'; - import { exitWithoutDependency, exposeConstant, @@ -39,8 +37,16 @@ import { exposeDependencyOrContinue, exposeUpdateValueOrContinue, exposeWhetherDependencyAvailable, + withResultOfAvailabilityCheck, } from '#composite/control-flow'; +import { + fillMissingListItems, + withFlattenedList, + withPropertyFromList, + withPropertyFromObject, +} from '#composite/data'; + import { withRecontextualizedContributionList, withRedatedContributionList, @@ -79,7 +85,6 @@ import { withCoverArtistContribs, withDate, withDirectorySuffix, - withHasUniqueCoverArt, withMainRelease, withMainReleaseTrack, withOtherReleases, @@ -535,9 +540,93 @@ export class Track extends Thing { exposeDependency({dependency: '#trackNumber'}), ], + // Whether or not the track has "unique" cover artwork - a cover which is + // specifically associated with this track in particular, rather than with + // the track's album as a whole. This is typically used to select between + // displaying the track artwork and a fallback, such as the album artwork + // or a placeholder. (This property is named hasUniqueCoverArt instead of + // the usual hasCoverArt to emphasize that it does not inherit from the + // album.) + // + // hasUniqueCoverArt is based only around the presence of *specified* + // cover artist contributions, not whether the references to artists on those + // contributions actually resolve to anything. It completely evades interacting + // with find/replace. hasUniqueCoverArt: [ - withHasUniqueCoverArt(), - exposeDependency({dependency: '#hasUniqueCoverArt'}), + { + dependencies: ['disableUniqueCoverArt'], + compute: (continuation, {disableUniqueCoverArt}) => + (disableUniqueCoverArt + ? false + : continuation()), + }, + + withResultOfAvailabilityCheck({ + from: '_coverArtistContribs', + mode: input.value('empty'), + }), + + { + dependencies: ['#availability'], + compute: (continuation, { + ['#availability']: availability, + }) => + (availability + ? true + : continuation()), + }, + + withPropertyFromAlbum({ + property: input.value('trackCoverArtistContribs'), + internal: input.value(true), + }), + + withResultOfAvailabilityCheck({ + from: '#album.trackCoverArtistContribs', + mode: input.value('empty'), + }), + + { + dependencies: ['#availability'], + compute: (continuation, { + ['#availability']: availability, + }) => + (availability + ? true + : continuation()), + }, + + exitWithoutDependency({ + dependency: '_trackArtworks', + mode: input.value('empty'), + value: input.value(false), + }), + + withPropertyFromList({ + list: '_trackArtworks', + property: input.value('artistContribs'), + internal: input.value(true), + }), + + // Since we're getting the update value for each artwork's artistContribs, + // it may not be set at all, and in that case won't be exposing as []. + fillMissingListItems({ + list: '#trackArtworks.artistContribs', + fill: input.value([]), + }), + + withFlattenedList({ + list: '#trackArtworks.artistContribs', + }), + + withResultOfAvailabilityCheck({ + from: '#flattenedList', + mode: input.value('empty'), + }), + + exposeDependency({ + dependency: '#availability', + }), ], isMainRelease: [ -- cgit 1.3.0-6-gf8a5