diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-19 16:47:45 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-03-02 08:24:12 -0400 |
commit | 586c3b9defc0d6222502f43a0cc4fa39c871a018 (patch) | |
tree | 3bbd9cc289b0c29e126a2aceec30ef3b6636bb9f /src/data/composite/things/track/withOtherReleases.js | |
parent | 76e508ffe3818a78fb941ecde05fe9c269e8bc22 (diff) |
data: miscellaneous cleanup for withOtherReleases logic
Defines withOtherReleases in terms of new function withAllReleases (also exposed as Track.allReleases), in turn based on new property Track.secondaryReleases (of the main release), which is a reverse ref list, reverse.tracksWhichAreSecondaryReleasesOf().
Diffstat (limited to 'src/data/composite/things/track/withOtherReleases.js')
-rw-r--r-- | src/data/composite/things/track/withOtherReleases.js | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/data/composite/things/track/withOtherReleases.js b/src/data/composite/things/track/withOtherReleases.js index 3fec8742..0639742f 100644 --- a/src/data/composite/things/track/withOtherReleases.js +++ b/src/data/composite/things/track/withOtherReleases.js @@ -1,8 +1,12 @@ +// Gets all releases of the current track *except* this track itself; +// in other words, all other releases of the current track. + import {input, templateCompositeFrom} from '#composite'; import {exitWithoutDependency} from '#composite/control-flow'; +import {withPropertyFromObject} from '#composite/data'; -import withMainRelease from './withMainRelease.js'; +import withAllReleases from './withAllReleases.js'; export default templateCompositeFrom({ annotation: `withOtherReleases`, @@ -10,32 +14,16 @@ export default templateCompositeFrom({ outputs: ['#otherReleases'], steps: () => [ - exitWithoutDependency({ - dependency: 'trackData', - mode: input.value('empty'), - }), - - withMainRelease({ - selfIfMain: input.value(true), - notFoundValue: input.value([]), - }), + withAllReleases(), - // TODO: Jegus shouldn't this be a proper reverse list { - dependencies: [input.myself(), '#mainRelease', 'trackData'], + dependencies: [input.myself(), '#allReleases'], compute: (continuation, { [input.myself()]: thisTrack, - ['#mainRelease']: mainRelease, - trackData, + ['#allReleases']: allReleases, }) => continuation({ ['#otherReleases']: - (mainRelease === thisTrack - ? [] - : [mainRelease]) - .concat(trackData.filter(track => - track !== mainRelease && - track !== thisTrack && - track.mainReleaseTrack === mainRelease)), + allReleases.filter(track => track !== thisTrack), }), }, ], |