« get me outta code hell

data: Track: chop withTrackNumber - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-11-25 17:01:21 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-11-25 17:01:38 -0400
commit3d6e0377e01a6c8c05ab3725cc0c30d02f318d0f (patch)
tree6ef6be388e45bfa94d55247ff499f59434c0d446 /src
parent8a20f2b849da363336d3f7f71b14762af954457f (diff)
data: Track: chop withTrackNumber
one """normative""" change: we're checking availability of #index
correctly now (in index mode)
Diffstat (limited to 'src')
-rw-r--r--src/data/composite/things/track/index.js1
-rw-r--r--src/data/composite/things/track/withTrackNumber.js46
-rw-r--r--src/data/things/track.js35
3 files changed, 32 insertions, 50 deletions
diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js
index 8036d4df..f392cb8e 100644
--- a/src/data/composite/things/track/index.js
+++ b/src/data/composite/things/track/index.js
@@ -4,4 +4,3 @@ export {default as inheritContributionListFromMainRelease} from './inheritContri
 export {default as inheritFromMainRelease} from './inheritFromMainRelease.js';
 export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js';
 export {default as withPropertyFromMainRelease} from './withPropertyFromMainRelease.js';
-export {default as withTrackNumber} from './withTrackNumber.js';
diff --git a/src/data/composite/things/track/withTrackNumber.js b/src/data/composite/things/track/withTrackNumber.js
deleted file mode 100644
index bb0f1366..00000000
--- a/src/data/composite/things/track/withTrackNumber.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import {raiseOutputWithoutDependency} from '#composite/control-flow';
-import {withIndexInList, withPropertiesFromObject} from '#composite/data';
-
-export default templateCompositeFrom({
-  annotation: `withTrackNumber`,
-
-  outputs: ['#trackNumber'],
-
-  steps: () => [
-    // Zero is the fallback, not one, but in most albums the first track
-    // (and its intended output by this composition) will be one.
-    raiseOutputWithoutDependency({
-      dependency: 'trackSection',
-      output: input.value({'#trackNumber': 0}),
-    }),
-
-    withPropertiesFromObject({
-      object: 'trackSection',
-      properties: input.value(['tracks', 'startCountingFrom']),
-    }),
-
-    withIndexInList({
-      list: '#trackSection.tracks',
-      item: input.myself(),
-    }),
-
-    raiseOutputWithoutDependency({
-      dependency: '#index',
-      output: input.value({'#trackNumber': 0}),
-    }),
-
-    {
-      dependencies: ['#trackSection.startCountingFrom', '#index'],
-      compute: (continuation, {
-        ['#trackSection.startCountingFrom']: startCountingFrom,
-        ['#index']: index,
-      }) => continuation({
-        ['#trackNumber']:
-          startCountingFrom +
-          index,
-      }),
-    },
-  ],
-});
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 31eed682..032171d0 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -49,7 +49,9 @@ import {
   fillMissingListItems,
   withFilteredList,
   withFlattenedList,
+  withIndexInList,
   withMappedList,
+  withPropertiesFromObject,
   withPropertyFromList,
   withPropertyFromObject,
 } from '#composite/data';
@@ -90,7 +92,6 @@ import {
   inheritContributionListFromMainRelease,
   inheritFromMainRelease,
   withPropertyFromAlbum,
-  withTrackNumber,
 } from '#composite/things/track';
 
 export class Track extends Thing {
@@ -657,8 +658,36 @@ export class Track extends Thing {
     ],
 
     trackNumber: [
-      withTrackNumber(),
-      exposeDependency({dependency: '#trackNumber'}),
+      // Zero is the fallback, not one, but in most albums the first track
+      // (and its intended output by this composition) will be one.
+      exitWithoutDependency({
+        dependency: 'trackSection',
+        value: input.value(0),
+      }),
+
+      withPropertiesFromObject({
+        object: 'trackSection',
+        properties: input.value(['tracks', 'startCountingFrom']),
+      }),
+
+      withIndexInList({
+        list: '#trackSection.tracks',
+        item: input.myself(),
+      }),
+
+      exitWithoutDependency({
+        dependency: '#index',
+        value: input.value(0),
+        mode: input.value('index'),
+      }),
+
+      {
+        dependencies: ['#trackSection.startCountingFrom', '#index'],
+        compute: ({
+          ['#trackSection.startCountingFrom']: startCountingFrom,
+          ['#index']: index,
+        }) => startCountingFrom + index,
+      },
     ],
 
     // Whether or not the track has "unique" cover artwork - a cover which is