« get me outta code hell

inherit hasTrackArt and use in getTrackCover util - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-02-25 20:26:12 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-02-25 20:26:12 -0400
commita7281f12ee5fc52f8b748bb1fb555a057e8e6677 (patch)
treeb19663c7ddf0700d3c339b0ee8e13e0f6fba8fe3 /src/data
parentadb267431909a3d263bb4f931fa49b2158f024f7 (diff)
inherit hasTrackArt and use in getTrackCover util
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/data/things.js b/src/data/things.js
index 330419c7..02697319 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -546,7 +546,6 @@ Track.propertyDescriptors = {
     urls: Thing.common.urls(),
     dateFirstReleased: Thing.common.simpleDate(),
 
-    hasCoverArt: Thing.common.flag(true),
     hasURLs: Thing.common.flag(true),
 
     referencedTracksByRef: Thing.common.referenceList(Track),
@@ -556,6 +555,18 @@ Track.propertyDescriptors = {
     contributorContribsByRef: Thing.common.contribsByRef(),
     coverArtistContribsByRef: Thing.common.contribsByRef(),
 
+    hasCoverArt: {
+        flags: {update: true, expose: true},
+
+        update: {validate: isBoolean},
+
+        expose: {
+            dependencies: ['albumData'],
+            transform: (hasCoverArt, { albumData, [Track.instance]: track }) => (
+                hasCoverArt ?? Track.findAlbum(track, albumData)?.hasTrackArt ?? true)
+        }
+    },
+
     // Previously known as: (track).aka
     originalReleaseTrackByRef: Thing.common.singleReference(Track),