« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/track.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/track.js')
-rw-r--r--src/data/things/track.js37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 2ee42fdf..a1740f87 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -5,7 +5,7 @@ import {colors} from '#cli';
 import {input} from '#composite';
 import find from '#find';
 import Thing from '#thing';
-import {isColor, isContributionList, isDate, isFileExtension}
+import {isBoolean, isColor, isContributionList, isDate, isFileExtension}
   from '#validators';
 
 import {
@@ -67,10 +67,12 @@ import {
   withAlwaysReferenceByDirectory,
   withContainingTrackSection,
   withDate,
+  withDirectorySuffix,
   withHasUniqueCoverArt,
   withOriginalRelease,
   withOtherReleases,
   withPropertyFromAlbum,
+  withSuffixDirectoryFromAlbum,
   withTrackArtDate,
 } from '#composite/things/track';
 
@@ -90,29 +92,34 @@ export class Track extends Thing {
     name: name('Unnamed Track'),
 
     directory: [
-      withPropertyFromAlbum({
-        property: input.value('directorySuffix'),
+      withDirectorySuffix(),
+
+      directory({
+        suffix: '#directorySuffix',
       }),
+    ],
 
+    suffixDirectoryFromAlbum: [
       {
-        dependencies: ['suffixDirectory', '#album.directorySuffix'],
+        dependencies: [
+          input.updateValue({validate: isBoolean}),
+        ],
+
         compute: (continuation, {
-          ['suffixDirectory']: suffixDirectory,
-          ['#album.directorySuffix']: directorySuffix,
+          [input.updateValue()]: value,
         }) => continuation({
-          ['#suffix']:
-            (suffixDirectory
-              ? directorySuffix
-              : null),
+          ['#flagValue']: value ?? false,
         }),
       },
 
-      directory({
-        suffix: '#suffix',
+      withSuffixDirectoryFromAlbum({
+        flagValue: '#flagValue',
       }),
-    ],
 
-    suffixDirectory: flag(false),
+      exposeDependency({
+        dependency: '#suffixDirectoryFromAlbum',
+      })
+    ],
 
     additionalNames: additionalNameList(),
 
@@ -458,7 +465,7 @@ export class Track extends Thing {
     fields: {
       'Track': {property: 'name'},
       'Directory': {property: 'directory'},
-      'Suffix Directory': {property: 'suffixDirectory'},
+      'Suffix Directory': {property: 'suffixDirectoryFromAlbum'},
 
       'Additional Names': {
         property: 'additionalNames',