« get me outta code hell

data: withResolvedReference: remove notFoundMode input - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/track
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-06 08:16:00 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-06 08:33:38 -0400
commit5eac956b82276d6342b4bbe6b10fac7b3a783bc4 (patch)
treeb2008e7fbd3ad1d338251483cda497339bf62e30 /src/data/composite/things/track
parent1b42f193421d5ca0376e006750b00b0e0b734607 (diff)
data: withResolvedReference: remove notFoundMode input
Diffstat (limited to 'src/data/composite/things/track')
-rw-r--r--src/data/composite/things/track/withOriginalRelease.js45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/data/composite/things/track/withOriginalRelease.js b/src/data/composite/things/track/withOriginalRelease.js
index d2ee39df..6e30a0a0 100644
--- a/src/data/composite/things/track/withOriginalRelease.js
+++ b/src/data/composite/things/track/withOriginalRelease.js
@@ -9,6 +9,8 @@ import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
 import {validateWikiData} from '#validators';
 
+import {exitWithoutDependency, withResultOfAvailabilityCheck}
+  from '#composite/control-flow';
 import {withResolvedReference} from '#composite/wiki-data';
 
 export default templateCompositeFrom({
@@ -26,33 +28,48 @@ export default templateCompositeFrom({
   outputs: ['#originalRelease'],
 
   steps: () => [
-    withResolvedReference({
-      ref: 'originalReleaseTrack',
-      data: input('data'),
-      find: input.value(find.track),
-      notFoundMode: input.value('exit'),
-    }).outputs({
-      ['#resolvedReference']: '#originalRelease',
+    withResultOfAvailabilityCheck({
+      from: 'originalReleaseTrack',
     }),
 
     {
       dependencies: [
         input.myself(),
         input('selfIfOriginal'),
-        '#originalRelease',
+        '#availability',
       ],
 
       compute: (continuation, {
         [input.myself()]: track,
         [input('selfIfOriginal')]: selfIfOriginal,
-        ['#originalRelease']: originalRelease,
+        '#availability': availability,
+      }) =>
+        (availability
+          ? continuation()
+          : continuation.raiseOutput({
+              ['#originalRelease']:
+                (selfIfOriginal ? track : null),
+            })),
+    },
+
+    withResolvedReference({
+      ref: 'originalReleaseTrack',
+      data: input('data'),
+      find: input.value(find.track),
+    }),
+
+    exitWithoutDependency({
+      dependency: '#resolvedReference',
+    }),
+
+    {
+      dependencies: ['#resolvedReference'],
+
+      compute: (continuation, {
+        ['#resolvedReference']: resolvedReference,
       }) =>
         continuation({
-          ['#originalRelease']:
-            (originalRelease ??
-              (selfIfOriginal
-                ? track
-                : null)),
+          ['#originalRelease']: resolvedReference,
         }),
     },
   ],