From c7d8ab3286854faa2ccf54e84b8efbff43a416fc Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 25 Aug 2023 13:29:38 -0300 Subject: data: Track.artistContribs: be lazy, like coverArtistContribs --- src/data/things/track.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/data/things') diff --git a/src/data/things/track.js b/src/data/things/track.js index 5c3a1d46..016f5199 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -303,25 +303,34 @@ export class Track extends Thing { artistContribs: Thing.composite.from(`Track.artistContribs`, [ Track.composite.inheritFromOriginalRelease({property: 'artistContribs'}), - Track.composite.withAlbumProperties({properties: ['artistContribs']}), Thing.composite.withResolvedContribs({ from: 'artistContribsByRef', to: '#artistContribs', }), { - flags: {expose: true}, + flags: {expose: true, compose: true}, expose: { - dependencies: ['#artistContribs', '#album.artistContribs'], - compute: ({ - '#artistContribs': contribsFromTrack, - '#album.artistContribs': contribsFromAlbum, - }) => + mapDependencies: {contribsFromTrack: '#artistContribs'}, + compute: ({contribsFromTrack}, continuation) => (empty(contribsFromTrack) - ? contribsFromAlbum + ? continuation() : contribsFromTrack), }, }, + + Track.composite.withAlbumProperties({properties: ['artistContribs']}), + + { + flags: {expose: true}, + expose: { + mapDependencies: {contribsFromAlbum: '#album.artistContribs'}, + compute: ({contribsFromAlbum}) => + (empty(contribsFromAlbum) + ? null + : contribsFromAlbum), + }, + }, ]), contributorContribs: Thing.composite.from(`Track.contributorContribs`, [ -- cgit 1.3.0-6-gf8a5