« get me outta code hell

data: Referenced Artworks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-14 20:11:42 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-15 20:40:14 -0400
commit18849547f4bed29da0b0ad8b69a74b4c2e83ef43 (patch)
treeb66e4bd95b2f19aa08b080bfd29c498aa7702ab2 /src/data/composite/wiki-properties
parent4f6e0bc351831abedca9dcb9667987b2907e0a61 (diff)
data: Referenced Artworks
Diffstat (limited to 'src/data/composite/wiki-properties')
-rw-r--r--src/data/composite/wiki-properties/referencedArtworkList.js60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/data/composite/wiki-properties/referencedArtworkList.js b/src/data/composite/wiki-properties/referencedArtworkList.js
index bd2962de..251944e5 100644
--- a/src/data/composite/wiki-properties/referencedArtworkList.js
+++ b/src/data/composite/wiki-properties/referencedArtworkList.js
@@ -1,45 +1,55 @@
 import {input, templateCompositeFrom} from '#composite';
-import {isThingClass, validateAnnotatedReferenceList} from '#validators';
+import find from '#find';
+import {validateAnnotatedReferenceList} from '#validators';
+import {combineWikiDataArrays} from '#wiki-data';
 
 import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withResolvedArtworkReferenceList} from '#composite/wiki-data';
+import {withResolvedArtworkReferenceList} from '#composite/wiki-data';
 
 export default templateCompositeFrom({
   annotation: `referencedArtworkList`,
 
-  inputs: {
-    class: input.staticValue({
-      validate: isThingClass,
-      acceptsNull: true,
-      defaultValue: null,
-    }),
-
-    referenceType: input.staticValue({
-      type: 'string',
-      acceptsNull: true,
-      defaultValue: null,
-    }),
-
-    data: inputWikiData({allowMixedTypes: false}),
-    find: input({type: 'function'}),
-  },
-
   update: ({
     [input.staticValue('class')]: thingClass,
     [input.staticValue('referenceType')]: referenceType,
   }) => ({
     validate:
-      validateAnnotatedReferenceList(
-        (thingClass
-          ? thingClass[Symbol.for('Thing.referenceType')]
-          : referenceType)),
+      validateAnnotatedReferenceList(['album', 'track']),
   }),
 
   steps: () => [
+    {
+      dependencies: [
+        'albumData',
+        'trackData',
+      ],
+
+      compute: (continuation, {
+        albumData,
+        trackData,
+      }) => continuation({
+        ['#data']:
+          combineWikiDataArrays([
+            albumData,
+            trackData,
+          ]),
+      }),
+    },
+
+    {
+      compute: (continuation) => continuation({
+        ['#find']:
+          find.mixed({
+            track: find.track,
+            album: find.album,
+          }),
+      }),
+    },
+
     withResolvedArtworkReferenceList({
       list: input.updateValue(),
-      data: input('data'),
-      find: input('find'),
+      data: '#data',
+      find: '#find',
     }),
 
     exposeDependency({dependency: '#resolvedArtworkReferenceList'}),