diff options
Diffstat (limited to 'src/data/composite/things/track')
-rw-r--r-- | src/data/composite/things/track/withAlbum.js | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/src/data/composite/things/track/withAlbum.js b/src/data/composite/things/track/withAlbum.js index 143e0971..03b840d4 100644 --- a/src/data/composite/things/track/withAlbum.js +++ b/src/data/composite/things/track/withAlbum.js @@ -1,15 +1,10 @@ // Gets the track's album. This will early exit if albumData is missing. // If there's no album whose list of tracks includes this track, the output // dependency will be null. -// -// This step models with Flash.withFlashAct. 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: `withAlbum`, @@ -17,42 +12,11 @@ export default templateCompositeFrom({ outputs: ['#album'], steps: () => [ - exitWithoutDependency({ - dependency: 'albumData', - mode: input.value('null'), + withUniqueReferencingThing({ + data: 'albumData', + list: input.value('tracks'), + }).outputs({ + ['#uniqueReferencingThing']: '#album', }), - - withPropertyFromList({ - list: 'albumData', - property: input.value('tracks'), - }), - - { - dependencies: [input.myself(), '#albumData.tracks'], - compute: (continuation, { - [input.myself()]: track, - ['#albumData.tracks']: trackLists, - }) => continuation({ - ['#albumIndex']: - trackLists.findIndex(tracks => tracks.includes(track)), - }), - }, - - raiseOutputWithoutDependency({ - dependency: '#albumIndex', - mode: input.value('index'), - output: input.value({'#album': null}), - }), - - { - dependencies: ['albumData', '#albumIndex'], - compute: (continuation, { - ['albumData']: albumData, - ['#albumIndex']: albumIndex, - }) => continuation.raiseOutput({ - ['#album']: - albumData[albumIndex], - }), - }, ], }); |