diff options
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 |
commit | 4cb5d1d0c231afad0175b2824320d0612f0eceef (patch) | |
tree | 0d3a8a49baa1b7df12b21c9ea61808d97c9d9aa1 /src/data | |
parent | 4362324b40da9daa54c9c6c3a821b0cccaec71a0 (diff) |
data: withContainingTrackSection: use withUniqueReferencingThing
Diffstat (limited to 'src/data')
-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', ]], |