« get me outta code hell

data: update Album.tracks - 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-09-08 11:32:50 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-08 11:32:50 -0300
commitbf0be010c9d9b860ad42762fc2e373130c7535eb (patch)
tree94c3f8b8d38c4ee2ae8d3dea6ce5e465e3a13ca7 /src
parentf82c43f594ee5eadde34c05d45b9ce7a14301a87 (diff)
data: update Album.tracks
Diffstat (limited to 'src')
-rw-r--r--src/data/things/album.js33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 3726a463..76e0f638 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -26,6 +26,7 @@ import Thing, {
   urls,
   wikiData,
   withResolvedContribs,
+  withResolvedReferenceList,
 } from './thing.js';
 
 export class Album extends Thing {
@@ -147,20 +148,30 @@ export class Album extends Thing {
     hasWallpaperArt: contribsPresent('wallpaperArtistContribs'),
     hasBannerArt: contribsPresent('bannerArtistContribs'),
 
-    tracks: {
-      flags: {expose: true},
+    tracks: compositeFrom(`Album.tracks`, [
+      exitWithoutDependency({
+        dependency: 'trackSections',
+        mode: 'empty',
+        value: [],
+      }),
 
-      expose: {
+      {
         dependencies: ['trackSections', 'trackData'],
-        compute: ({trackSections, trackData}) =>
-          (trackSections && trackData
-            ? trackSections
-                .flatMap(section => section.tracks ?? [])
-                .map(ref => find.track(ref, trackData, {mode: 'quiet'}))
-                .filter(Boolean)
-            : []),
+        compute: ({trackSections, trackData}, continuation) =>
+          continuation({
+            '#trackRefs': trackSections
+              .flatMap(section => section.tracks ?? []),
+          }),
       },
-    },
+
+      withResolvedReferenceList({
+        list: '#trackRefs',
+        data: 'trackData',
+        find: find.track,
+      }),
+
+      exposeDependency({dependency: '#resolvedReferenceList'}),
+    ]),
   });
 
   static [Thing.getSerializeDescriptors] = ({