From 287de65cea2fb72833eb2fe596f7e61c61939481 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 24 Aug 2023 19:00:14 -0300 Subject: data: Track.coverArtistContribs: lazier steps --- src/data/things/track.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/data/things/track.js b/src/data/things/track.js index 74f5d7fb..2a3148ef 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -344,28 +344,36 @@ export class Track extends Thing { }, }, - Track.composite.withAlbumProperties({ - properties: ['trackCoverArtistContribs'], - }), - Thing.composite.withResolvedContribs({ from: 'coverArtistContribsByRef', to: '#coverArtistContribs', }), { - flags: {expose: true}, + flags: {expose: true, compose: true}, expose: { - dependencies: ['#coverArtistContribs', '#album.trackCoverArtistContribs'], - compute: ({ - '#coverArtistContribs': contribsFromTrack, - '#album.trackCoverArtistContribs': contribsFromAlbum, - }) => + mapDependencies: {contribsFromTrack: '#coverArtistContribs'}, + compute: ({contribsFromTrack}, continuation) => (empty(contribsFromTrack) - ? contribsFromAlbum + ? continuation() : contribsFromTrack), }, }, + + Track.composite.withAlbumProperties({ + properties: ['trackCoverArtistContribs'], + }), + + { + flags: {expose: true}, + expose: { + mapDependencies: {contribsFromAlbum: '#album.trackCoverArtistContribs'}, + compute: ({contribsFromAlbum}) => + (empty(contribsFromAlbum) + ? null + : contribsFromAlbum), + }, + }, ]), referencedTracks: Thing.composite.from(`Track.referencedTracks`, [ -- cgit 1.3.0-6-gf8a5