diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-26 17:32:28 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-26 17:32:28 -0400 |
commit | 49537d408b17f7583cd00d0866f5de6797a0591e (patch) | |
tree | d7b811bb4c6fc0042ec56847b91ecdebe74ca1f2 /src/data/composite/things/track/withSharedAdditionalNames.js | |
parent | 09f67bdb9438618fe8632d0d8ceda8fee12b8cb7 (diff) |
data: shared & inferred additional names (for tracks)
Diffstat (limited to 'src/data/composite/things/track/withSharedAdditionalNames.js')
-rw-r--r-- | src/data/composite/things/track/withSharedAdditionalNames.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/data/composite/things/track/withSharedAdditionalNames.js b/src/data/composite/things/track/withSharedAdditionalNames.js new file mode 100644 index 00000000..d205dc89 --- /dev/null +++ b/src/data/composite/things/track/withSharedAdditionalNames.js @@ -0,0 +1,46 @@ +// Compiles additional names directly provided on other releases. + +import {input, templateCompositeFrom} from '#composite'; + +import {raiseOutputWithoutDependency} from '#composite/control-flow'; +import {withFlattenedList} from '#composite/data'; + +import CacheableObject from '#cacheable-object'; + +import withOtherReleases from './withOtherReleases.js'; + +export default templateCompositeFrom({ + annotation: `withSharedAdditionalNames`, + + outputs: ['#sharedAdditionalNames'], + + steps: () => [ + withOtherReleases(), + + raiseOutputWithoutDependency({ + dependency: '#otherReleases', + mode: input.value('empty'), + output: input.value({'#inferredAdditionalNames': []}), + }), + + // TODO: Using getUpdateValue is always a bit janky. + + { + dependencies: ['#otherReleases'], + compute: (continuation, { + ['#otherReleases']: otherReleases, + }) => continuation({ + ['#otherReleases.additionalNames']: + otherReleases.map(release => + CacheableObject.getUpdateValue(release, 'additionalNames') + ?? []), + }), + }, + + withFlattenedList({ + list: '#otherReleases.additionalNames', + }).outputs({ + '#flattenedList': '#sharedAdditionalNames', + }), + ], +}); |