« get me outta code hell

per-track color support - 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>2023-03-02 20:46:16 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-03-02 20:46:16 -0400
commite1db565e4059a2e26e2c0e56a6f3f3ae738ea2b7 (patch)
treea1853ac2ced8a39e36e3efdaa8292fafd6a49194 /src
parent3ff4dbee48dbbf323666ec86e3ad9363a83f910e (diff)
per-track color support
Diffstat (limited to 'src')
-rw-r--r--src/data/things/track.js14
-rw-r--r--src/data/yaml.js1
2 files changed, 10 insertions, 5 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 0751b2d0..1c2013a2 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -16,6 +16,7 @@ export class Track extends Thing {
 
     validators: {
       isBoolean,
+      isColor,
       isDate,
       isDuration,
       isFileExtension,
@@ -145,15 +146,18 @@ export class Track extends Thing {
     },
 
     color: {
-      flags: {expose: true},
+      flags: {update: true, expose: true},
+
+      update: {validate: isColor},
 
       expose: {
         dependencies: ['albumData'],
 
-        compute: ({albumData, [Track.instance]: track}) =>
-          Track.findAlbum(track, albumData)
-            ?.trackSections.find(({tracks}) => tracks.includes(track))
-              ?.color ?? null,
+        transform: (color, {albumData, [Track.instance]: track}) =>
+          color ??
+            Track.findAlbum(track, albumData)
+              ?.trackSections.find(({tracks}) => tracks.includes(track))
+                ?.color ?? null,
       },
     },
 
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 6b5156ef..1b1195ea 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -256,6 +256,7 @@ export const processTrackDocument = makeProcessDocument(T.Track, {
     name: 'Track',
     directory: 'Directory',
     duration: 'Duration',
+    color: 'Color',
     urls: 'URLs',
 
     dateFirstReleased: 'Date First Released',