« get me outta code hell

Merge branch 'preview' into track-data-cleanup - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-19 10:00:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-19 10:00:21 -0300
commitc6c1a6be4ee817c65ccc994cd6ae68a835aa406e (patch)
tree23e07252b71329bf99aad400aa0ca93eb59ba532 /src/data/things
parentfd102ee597e2ad2ba8f0950ce1a16fd34029963d (diff)
parentfdd8f355bfe0992fc340f800297df524276b1946 (diff)
Merge branch 'preview' into track-data-cleanup
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/track.js61
1 files changed, 49 insertions, 12 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index b41dbb5b..28caf1de 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -61,17 +61,51 @@ export class Track extends Thing {
     dateFirstReleased: simpleDate(),
 
     color: [
-      exposeUpdateValueOrContinue(),
+      exposeUpdateValueOrContinue({
+        validate: input.value(isColor),
+      }),
 
       withContainingTrackSection(),
       withPropertyFromObject({object: '#trackSection', property: 'color'}),
       exposeDependencyOrContinue({dependency: '#trackSection.color'}),
 
       withPropertyFromAlbum({property: 'color'}),
-      exposeDependency({
-        dependency: '#album.color',
-        update: {validate: isColor},
+      exposeDependency({dependency: '#album.color'}),
+    ],
+
+    // Controls how find.track works - it'll never be matched by a reference
+    // just to the track's name, which means you don't have to always reference
+    // some *other* (much more commonly referenced) track by directory instead
+    // of more naturally by name.
+    alwaysReferenceByDirectory: [
+      exposeUpdateValueOrContinue({
+        validate: input.value(isBoolean),
       }),
+
+      excludeFromList({
+        list: 'trackData',
+        item: input.myself(),
+      }),
+
+      withOriginalRelease({
+        data: '#trackData',
+      }),
+
+      exitWithoutDependency({
+        dependency: '#originalRelease',
+        value: input.value(false),
+      }),
+
+      withPropertyFromObject({
+        object: '#originalRelease',
+        property: input.value('name'),
+      }),
+
+      {
+        dependencies: ['name', '#originalRelease.name'],
+        compute({name, '#originalRelease.name': originalName}) =>
+          name === originalName,
+      },
     ],
 
     // Disables presenting the track as though it has its own unique artwork.
@@ -506,6 +540,9 @@ export const withOriginalRelease = templateCompositeFrom({
 
   inputs: {
     selfIfOriginal: input({type: 'boolean', defaultValue: false}),
+
+    // todo: validate
+    data: input({defaultDependency: 'trackData'}),
   },
 
   outputs: {
@@ -513,14 +550,14 @@ export const withOriginalRelease = templateCompositeFrom({
   },
 
   steps: () => [
-    withResolvedReference
-      .inputs({
-        ref: 'originalReleaseTrack',
-        data: 'trackData',
-        find: input.value(find.track),
-        notFoundMode: input.value('exit'),
-      })
-      .outputs({into: '#originalRelease'}),
+    withResolvedReference({
+      ref: 'originalReleaseTrack',
+      data: input('data'),
+      find: input.value(find.track),
+      notFoundMode: input.value('exit'),
+    }).outputs({
+      '#resolvedReference': '#originalRelease',
+    }),
 
     {
       dependencies: [