« get me outta code hell

data: Track.coverArtistContribs: lazier steps - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-24 19:00:14 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-05 21:02:51 -0300
commit287de65cea2fb72833eb2fe596f7e61c61939481 (patch)
treee0d5438467da71b6cf72d491489d6c0514f1ee92 /src
parent57edc116016f45f1bc9e7e3e6560450b6c480602 (diff)
data: Track.coverArtistContribs: lazier steps
Diffstat (limited to 'src')
-rw-r--r--src/data/things/track.js30
1 files changed, 19 insertions, 11 deletions
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`, [