« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/track.js14
1 files changed, 9 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,
       },
     },