diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 17:05:17 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 17:05:17 -0400 |
| commit | 697a92ab17dda83b281329843eba8da626caf226 (patch) | |
| tree | 90d592621d15a510102fe64a995484ce1a89ca46 /src/data | |
| parent | 3d6e0377e01a6c8c05ab3725cc0c30d02f318d0f (diff) | |
data: Track: inline alwaysReferenceByDirectory
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/composite/things/track/alwaysReferenceByDirectory.js | 66 | ||||
| -rw-r--r-- | src/data/composite/things/track/index.js | 1 | ||||
| -rw-r--r-- | src/data/things/track.js | 47 |
3 files changed, 45 insertions, 69 deletions
diff --git a/src/data/composite/things/track/alwaysReferenceByDirectory.js b/src/data/composite/things/track/alwaysReferenceByDirectory.js deleted file mode 100644 index b1b0d531..00000000 --- a/src/data/composite/things/track/alwaysReferenceByDirectory.js +++ /dev/null @@ -1,66 +0,0 @@ -// Controls how find.track works - it'll never be matched by a reference -// just to the track's name, which means you don't have to always reference -// some *other* (much more commonly referenced) track by directory instead -// of more naturally by name. - -import {input, templateCompositeFrom} from '#composite'; -import {isBoolean} from '#validators'; -import {getKebabCase} from '#wiki-data'; - -import {withPropertyFromObject} from '#composite/data'; - -import { - exitWithoutDependency, - exposeDependencyOrContinue, - exposeUpdateValueOrContinue, -} from '#composite/control-flow'; - -import withPropertyFromAlbum from './withPropertyFromAlbum.js'; - -export default templateCompositeFrom({ - annotation: `alwaysReferenceByDirectory`, - - compose: false, - - steps: () => [ - exposeUpdateValueOrContinue({ - validate: input.value(isBoolean), - }), - - withPropertyFromAlbum({ - property: input.value('alwaysReferenceTracksByDirectory'), - }), - - // Falsy mode means this exposes true if the album's property is true, - // but continues if the property is false (which is also the default). - exposeDependencyOrContinue({ - dependency: '#album.alwaysReferenceTracksByDirectory', - mode: input.value('falsy'), - }), - - exitWithoutDependency({ - dependency: '_mainRelease', - value: input.value(false), - }), - - exitWithoutDependency({ - dependency: 'mainReleaseTrack', - value: input.value(false), - }), - - withPropertyFromObject({ - object: 'mainReleaseTrack', - property: input.value('name'), - }), - - { - dependencies: ['name', '#mainReleaseTrack.name'], - compute: ({ - ['name']: name, - ['#mainReleaseTrack.name']: mainReleaseName, - }) => - getKebabCase(name) === - getKebabCase(mainReleaseName), - }, - ], -}); diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js index f392cb8e..70b371a7 100644 --- a/src/data/composite/things/track/index.js +++ b/src/data/composite/things/track/index.js @@ -1,4 +1,3 @@ -export {default as alwaysReferenceByDirectory} from './alwaysReferenceByDirectory.js'; export {default as exitWithoutUniqueCoverArt} from './exitWithoutUniqueCoverArt.js'; export {default as inheritContributionListFromMainRelease} from './inheritContributionListFromMainRelease.js'; export {default as inheritFromMainRelease} from './inheritFromMainRelease.js'; diff --git a/src/data/things/track.js b/src/data/things/track.js index 032171d0..f275b509 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -87,7 +87,6 @@ import { } from '#composite/wiki-properties'; import { - alwaysReferenceByDirectory, exitWithoutUniqueCoverArt, inheritContributionListFromMainRelease, inheritFromMainRelease, @@ -154,7 +153,51 @@ export class Track extends Thing { }), ], - alwaysReferenceByDirectory: alwaysReferenceByDirectory(), + // Controls how find.track works - it'll never be matched by + // a reference just to the track's name, which means you don't + // have to always reference some *other* (much more commonly + // referenced) track by directory instead of more naturally by name. + alwaysReferenceByDirectory: [ + exposeUpdateValueOrContinue({ + validate: input.value(isBoolean), + }), + + withPropertyFromAlbum({ + property: input.value('alwaysReferenceTracksByDirectory'), + }), + + // Falsy mode means this exposes true if the album's property is true, + // but continues if the property is false (which is also the default). + exposeDependencyOrContinue({ + dependency: '#album.alwaysReferenceTracksByDirectory', + mode: input.value('falsy'), + }), + + exitWithoutDependency({ + dependency: '_mainRelease', + value: input.value(false), + }), + + exitWithoutDependency({ + dependency: 'mainReleaseTrack', + value: input.value(false), + }), + + withPropertyFromObject({ + object: 'mainReleaseTrack', + property: input.value('name'), + }), + + { + dependencies: ['name', '#mainReleaseTrack.name'], + compute: ({ + ['name']: name, + ['#mainReleaseTrack.name']: mainReleaseName, + }) => + getKebabCase(name) === + getKebabCase(mainReleaseName), + }, + ], // Album or track. The exposed value is really just what's provided here, // whether or not a matching track is found on a provided album, for |