From 4cb5d1d0c231afad0175b2824320d0612f0eceef Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 5 Aug 2024 13:17:21 -0300 Subject: data: withContainingTrackSection: use withUniqueReferencingThing --- .../things/track/withContainingTrackSection.js | 33 ++++------------------ 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'src/data/composite/things') 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, - }), - }, ], }); -- cgit 1.3.0-6-gf8a5