diff options
-rw-r--r-- | src/data/composite/things/track/withContainingTrackSection.js | 33 | ||||
-rw-r--r-- | src/data/things/track.js | 5 | ||||
-rw-r--r-- | src/data/yaml.js | 1 |
3 files changed, 12 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, - }), - }, ], }); diff --git a/src/data/things/track.js b/src/data/things/track.js index 48201687..faa5d7ef 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -82,6 +82,7 @@ export class Track extends Thing { ArtTag, Artist, Flash, + TrackSection, WikiInfo, }) => ({ // Update & expose @@ -344,6 +345,10 @@ export class Track extends Thing { class: input.value(Track), }), + trackSectionData: wikiData({ + class: input.value(TrackSection), + }), + wikiInfo: thing({ class: input.value(WikiInfo), }), diff --git a/src/data/yaml.js b/src/data/yaml.js index ffa24669..ffda5991 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1203,6 +1203,7 @@ export function linkWikiDataArrays(wikiData) { 'artistData', 'flashData', 'trackData', + 'trackSectionData', 'wikiInfo', ]], |