diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-23 12:22:11 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-09-05 21:02:50 -0300 |
commit | 94f684138329e17ab43bfe552056d7ea3ed28b17 (patch) | |
tree | f5b23f9dc8dfbbf4662b344a07c4549fcb2c9ca9 | |
parent | c7e624684069fb9325c426500a5fcc153cf26b41 (diff) |
data: track.hasUniqueCoverArt: operate on resolved contributions
-rw-r--r-- | src/data/things/track.js | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js index 118e3db0..414d5f29 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -223,29 +223,45 @@ export class Track extends Thing { // the usual hasCoverArt to emphasize that it does not inherit from the // album.) hasUniqueCoverArt: Thing.composite.from(`Track.hasUniqueCoverArt`, [ + { + flags: {expose: true, compose: true}, + expose: { + dependencies: ['disableUniqueCoverArt'], + compute: ({disableUniqueCoverArt}, continuation) => + (disableUniqueCoverArt + ? false + : continuation()), + }, + }, + + Thing.composite.withResolvedContribs({ + from: 'coverArtistContribsByRef', + to: '#coverArtistContribs', + }), + + { + flags: {expose: true, compose: true}, + expose: { + dependencies: ['#coverArtistContribs'], + compute: ({'#coverArtistContribs': coverArtistContribs}, continuation) => + (empty(coverArtistContribs) + ? continuation() + : true), + }, + }, + Track.composite.withAlbumProperties({ - properties: ['trackCoverArtistContribsByRef'], + properties: ['trackCoverArtistContribs'], }), { flags: {expose: true}, expose: { - dependencies: [ - 'coverArtistContribsByRef', - 'disableUniqueCoverArt', - '#album.trackCoverArtistContribsByRef', - ], - - compute({ - coverArtistContribsByRef, - disableUniqueCoverArt, - '#album.trackCoverArtistContribsByRef': trackCoverArtistContribsByRef, - }) { - if (disableUniqueCoverArt) return false; - if (!empty(coverArtistContribsByRef)) return true; - if (!empty(trackCoverArtistContribsByRef)) return true; - return false; - }, + dependencies: ['#album.trackCoverArtistContribs'], + compute: ({'#album.trackCoverArtistContribs': trackCoverArtistContribs}) => + (empty(trackCoverArtistContribs) + ? false + : true), }, }, ]), |