« get me outta code hell

data: remove 'Has Track Art', compute from credits - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/track.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-14 21:52:03 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-14 22:27:32 -0300
commit9332da311819d4ec9fa19b327271e3fab1dc49e8 (patch)
tree049e796b7b0e8f64aa4ad9efc2043a598ce8e645 /src/data/things/track.js
parentfa834b03fcc1cc65dcb299fe8a5ef55bc5426c1e (diff)
data: remove 'Has Track Art', compute from credits
Diffstat (limited to 'src/data/things/track.js')
-rw-r--r--src/data/things/track.js43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 00585c1e..a0a4ff41 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -1,9 +1,10 @@
 import Thing from './thing.js';
 
 import {inspect} from 'util';
-import {color} from '../../util/cli.js';
 
+import {color} from '../../util/cli.js';
 import find from '../../util/find.js';
+import {empty} from '../../util/sugar.js';
 
 export class Track extends Thing {
   static [Thing.referenceType] = 'track';
@@ -332,36 +333,44 @@ export class Track extends Thing {
     albumData?.find((album) => album.tracks.includes(track));
 
   // Another reused utility function. This one's logic is a bit more complicated.
-  static hasCoverArt = (
+  static hasCoverArt(
     track,
     albumData,
     coverArtistContribsByRef,
     hasCoverArt
-  ) => (
-    hasCoverArt ??
-    (coverArtistContribsByRef?.length > 0 || null) ??
-    Track.findAlbum(track, albumData)?.hasTrackArt ??
-    true
-  );
-
-  // Now this is a doozy!
+  ) {
+    if (!empty(coverArtistContribsByRef)) {
+      return true;
+    }
+
+    const album = Track.findAlbum(track, albumData);
+    if (album && !empty(album.trackCoverArtistContribsByRef)) {
+      return true;
+    }
+
+    return false;
+  }
+
   static hasUniqueCoverArt(
     track,
     albumData,
     coverArtistContribsByRef,
     hasCoverArt
   ) {
-    if (coverArtistContribsByRef?.length > 0) {
+    if (!empty(coverArtistContribsByRef)) {
       return true;
-    } else if (coverArtistContribsByRef) {
-      return false;
-    } else if (hasCoverArt === false) {
+    }
+
+    if (hasCoverArt === false) {
       return false;
-    } else if (Track.findAlbum(track, albumData)?.hasTrackArt) {
+    }
+
+    const album = Track.findAlbum(track, albumData);
+    if (album && !empty(album.trackCoverArtistContribsByRef)) {
       return true;
-    } else {
-      return false;
     }
+
+    return false;
   }
 
   [inspect.custom]() {