« get me outta code hell

non-jpg full res art links, artist avatars - 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-03-05 21:34:59 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-03-05 21:34:59 -0400
commit3bbeea69c6356edd5792ac7898b9623c2e1519de (patch)
treebd8727673d528e5b540db2b2dc51627ca209819b /src/data
parent21c6220356b3769b6321bd64e85398fee618cfb1 (diff)
non-jpg full res art links, artist avatars
Diffstat (limited to 'src/data')
-rw-r--r--src/data/cacheable-object.js2
-rw-r--r--src/data/things.js20
2 files changed, 21 insertions, 1 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index 99280956..4afb0368 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -169,7 +169,7 @@ export default class CacheableObject {
             const oldValue = this.#propertyUpdateValues[property];
 
             if (newValue === undefined) {
-                throw new ValueError(`Properties cannot be set to undefined`);
+                throw new TypeError(`Properties cannot be set to undefined`);
             }
 
             if (newValue === oldValue) {
diff --git a/src/data/things.js b/src/data/things.js
index c93b8852..16970af5 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -448,6 +448,9 @@ Album.propertyDescriptors = {
         }
     },
 
+    coverArtFileExtension: Thing.common.fileExtension('jpg'),
+    trackCoverArtFileExtension: Thing.common.fileExtension('jpg'),
+
     wallpaperStyle: Thing.common.simpleString(),
     wallpaperFileExtension: Thing.common.fileExtension('jpg'),
 
@@ -605,6 +608,20 @@ Track.propertyDescriptors = {
         }
     },
 
+    coverArtFileExtension: {
+        flags: {update: true, expose: true},
+
+        update: {validate: isFileExtension},
+
+        expose: {
+            dependencies: ['albumData'],
+            transform: (coverArtFileExtension, { albumData, [Track.instance]: track }) => (
+                coverArtFileExtension ??
+                Track.findAlbum(track, albumData)?.trackCoverArtFileExtension ??
+                true)
+        }
+    },
+
     // Previously known as: (track).aka
     originalReleaseTrackByRef: Thing.common.singleReference(Track),
 
@@ -779,6 +796,9 @@ Artist.propertyDescriptors = {
     urls: Thing.common.urls(),
     contextNotes: Thing.common.simpleString(),
 
+    hasAvatar: Thing.common.flag(false),
+    avatarFileExtension: Thing.common.fileExtension('jpg'),
+
     aliasNames: {
         flags: {update: true, expose: true},
         update: {