« 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
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
parentadb267431909a3d263bb4f931fa49b2158f024f7 (diff)
inherit hasTrackArt and use in getTrackCover util
-rw-r--r--src/data/things.js13
-rw-r--r--src/util/wiki-data.js2
2 files changed, 13 insertions, 2 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),
 
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 41071d17..36c61454 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -159,7 +159,7 @@ export function getTotalDuration(tracks) {
 export function getTrackCover(track, {to}) {
     // Some al8ums don't have any track art at all, and in those, every track
     // just inherits the al8um's own cover art.
-    if (track.coverArtists === null) {
+    if (!track.hasCoverArt) {
         return getAlbumCover(track.album, {to});
     } else {
         return to('media.trackCover', track.album.directory, track.directory);