« get me outta code hell

data: withContainingTrackSection: use withUniqueReferencingThing - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-08-05 13:17:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-08-05 20:42:09 -0300
commit4cb5d1d0c231afad0175b2824320d0612f0eceef (patch)
tree0d3a8a49baa1b7df12b21c9ea61808d97c9d9aa1 /src/data/composite/things
parent4362324b40da9daa54c9c6c3a821b0cccaec71a0 (diff)
data: withContainingTrackSection: use withUniqueReferencingThing
Diffstat (limited to 'src/data/composite/things')
-rw-r--r--src/data/composite/things/track/withContainingTrackSection.js33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/data/composite/things/track/withContainingTrackSection.js b/src/data/composite/things/track/withContainingTrackSection.js
index 2c42709b..9bbd9bd5 100644
--- a/src/data/composite/things/track/withContainingTrackSection.js
+++ b/src/data/composite/things/track/withContainingTrackSection.js
@@ -1,11 +1,8 @@
 // Gets the track section containing this track from its album's track list.
 
 import {input, templateCompositeFrom} from '#composite';
-import {is} from '#validators';
 
-import {raiseOutputWithoutDependency} from '#composite/control-flow';
-
-import withPropertyFromAlbum from './withPropertyFromAlbum.js';
+import {withUniqueReferencingThing} from '#composite/wiki-data';
 
 export default templateCompositeFrom({
   annotation: `withContainingTrackSection`,
@@ -13,29 +10,11 @@ export default templateCompositeFrom({
   outputs: ['#trackSection'],
 
   steps: () => [
-    withPropertyFromAlbum({
-      property: input.value('trackSections'),
-    }),
-
-    raiseOutputWithoutDependency({
-      dependency: '#album.trackSections',
-      output: input.value({'#trackSection': null}),
+    withUniqueReferencingThing({
+      data: 'trackSectionData',
+      list: input.value('tracks'),
+    }).outputs({
+      ['#uniqueReferencingThing']: '#trackSection',
     }),
-
-    {
-      dependencies: [
-        input.myself(),
-        '#album.trackSections',
-      ],
-
-      compute: (continuation, {
-        [input.myself()]: track,
-        ['#album.trackSections']: trackSections,
-      }) => continuation({
-        ['#trackSection']:
-          trackSections.find(({tracks}) => tracks.includes(track))
-            ?? null,
-      }),
-    },
   ],
 });