« 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.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 0842bf23..880f65fe 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -187,6 +187,26 @@ export class Track extends Thing {
       },
     },
 
+    hasUniqueCoverArt: {
+      flags: {expose: true},
+
+      expose: {
+        dependencies: ['albumData', 'coverArtistContribsByRef', 'hasCoverArt'],
+        compute: ({
+          albumData,
+          coverArtistContribsByRef,
+          hasCoverArt,
+          [Track.instance]: track,
+        }) =>
+          Track.hasUniqueCoverArt(
+            track,
+            albumData,
+            coverArtistContribsByRef,
+            hasCoverArt
+          ),
+      },
+    },
+
     originalReleaseTrack: Thing.common.dynamicThingFromSingleReference(
       'originalReleaseTrackByRef',
       'trackData',
@@ -324,6 +344,26 @@ export class Track extends Thing {
     true
   );
 
+  // Now this is a doozy!
+  static hasUniqueCoverArt(
+    track,
+    albumData,
+    coverArtistContribsByRef,
+    hasCoverArt
+  ) {
+    if (coverArtistContribsByRef?.length > 0) {
+      return true;
+    } else if (coverArtistContribsByRef) {
+      return false;
+    } else if (hasCoverArt === false) {
+      return false;
+    } else if (Track.findAlbum(track, albumData)?.hasTrackArt) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
   [inspect.custom]() {
     const base = Thing.prototype[inspect.custom].apply(this);