« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/flash
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/things/flash')
-rw-r--r--src/data/composite/things/flash/withFlashAct.js48
1 files changed, 6 insertions, 42 deletions
diff --git a/src/data/composite/things/flash/withFlashAct.js b/src/data/composite/things/flash/withFlashAct.js
index 2c985fe0..652b8bfb 100644
--- a/src/data/composite/things/flash/withFlashAct.js
+++ b/src/data/composite/things/flash/withFlashAct.js
@@ -1,15 +1,10 @@
 // Gets the flash's act. This will early exit if flashActData is missing.
 // If there's no flash whose list of flashes includes this flash, the output
 // dependency will be null.
-//
-// This step models with Flash.withAlbum.
 
 import {input, templateCompositeFrom} from '#composite';
-import {is} from '#validators';
 
-import {exitWithoutDependency, raiseOutputWithoutDependency}
-  from '#composite/control-flow';
-import {withPropertyFromList} from '#composite/data';
+import {withUniqueReferencingThing} from '#composite/wiki-data';
 
 export default templateCompositeFrom({
   annotation: `withFlashAct`,
@@ -17,42 +12,11 @@ export default templateCompositeFrom({
   outputs: ['#flashAct'],
 
   steps: () => [
-    exitWithoutDependency({
-      dependency: 'flashActData',
-      mode: input.value('null'),
+    withUniqueReferencingThing({
+      data: 'flashActData',
+      list: input.value('flashes'),
+    }).outputs({
+      ['#uniqueReferencingThing']: '#flashAct',
     }),
-
-    withPropertyFromList({
-      list: 'flashActData',
-      property: input.value('flashes'),
-    }),
-
-    {
-      dependencies: [input.myself(), '#flashActData.flashes'],
-      compute: (continuation, {
-        [input.myself()]: track,
-        ['#flashActData.flashes']: flashLists,
-      }) => continuation({
-        ['#flashActIndex']:
-          flashLists.findIndex(flashes => flashes.includes(track)),
-      }),
-    },
-
-    raiseOutputWithoutDependency({
-      dependency: '#flashActIndex',
-      mode: input.value('index'),
-      output: input.value({'#album': null}),
-    }),
-
-    {
-      dependencies: ['flashActData', '#flashActIndex'],
-      compute: (continuation, {
-        ['flashActData']: flashActData,
-        ['#flashActIndex']: flashActIndex,
-      }) => continuation.raiseOutput({
-        ['#flashAct']:
-          flashActData[flashActIndex],
-      }),
-    },
   ],
 });