« get me outta code hell

content: don't access referenceType - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-07-10 08:51:46 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-07-10 08:51:46 -0300
commit2f3785bd381685e97e6cb9fe9f3b69976973930d (patch)
treeed1d4d97616bec67701d241ffd83b43028886904 /src
parent09cf76c058c7e42274df33661cfb41c2d73609d1 (diff)
content: don't access referenceType
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateContributionTooltipChronologySection.js6
-rw-r--r--src/content/dependencies/generateCoverArtworkOriginDetails.js15
-rw-r--r--src/content/dependencies/linkAnythingMan.js14
-rw-r--r--src/content/dependencies/linkArtwork.js11
-rw-r--r--src/content/dependencies/linkReferencedArtworks.js13
-rw-r--r--src/content/dependencies/linkReferencingArtworks.js13
6 files changed, 20 insertions, 52 deletions
diff --git a/src/content/dependencies/generateContributionTooltipChronologySection.js b/src/content/dependencies/generateContributionTooltipChronologySection.js
index 378c0e1c..9f419a66 100644
--- a/src/content/dependencies/generateContributionTooltipChronologySection.js
+++ b/src/content/dependencies/generateContributionTooltipChronologySection.js
@@ -1,13 +1,9 @@
-import Thing from '#thing';
-
 function getName(thing) {
   if (!thing) {
     return null;
   }
 
-  const referenceType = thing.constructor[Thing.referenceType];
-
-  if (referenceType === 'artwork') {
+  if (thing.isArtwork) {
     return thing.thing.name;
   }
 
diff --git a/src/content/dependencies/generateCoverArtworkOriginDetails.js b/src/content/dependencies/generateCoverArtworkOriginDetails.js
index 5a7768fc..ddd44286 100644
--- a/src/content/dependencies/generateCoverArtworkOriginDetails.js
+++ b/src/content/dependencies/generateCoverArtworkOriginDetails.js
@@ -1,5 +1,3 @@
-import Thing from '#thing';
-
 export default {
   contentDependencies: [
     'generateArtistCredit',
@@ -11,9 +9,6 @@ export default {
   extraDependencies: ['html', 'language', 'pagePath'],
 
   query: (artwork) => ({
-    artworkThingType:
-      artwork.thing.constructor[Thing.referenceType],
-
     attachedArtistContribs:
       (artwork.attachedArtwork
         ? artwork.attachedArtwork.artistContribs
@@ -33,7 +28,7 @@ export default {
       relation('transformContent', artwork.originDetails),
 
     albumLink:
-      (query.artworkThingType === 'album'
+      (artwork.thing.isAlbum
         ? relation('linkAlbum', artwork.thing)
         : null),
 
@@ -48,11 +43,11 @@ export default {
     label:
       artwork.label,
 
-    artworkThingType:
-      query.artworkThingType,
+    forAlbum:
+      artwork.thing.isAlbum,
 
     forSingleStyleAlbum:
-      query.artworkThingType === 'album' &&
+      artwork.thing.isAlbum &&
       artwork.thing.style === 'single',
   }),
 
@@ -101,7 +96,7 @@ export default {
 
           const trackArtFromAlbum =
             pagePath[0] === 'track' &&
-            data.artworkThingType === 'album' &&
+            data.forAlbum &&
             !data.forSingleStyleAlbum &&
               language.$(capsule, 'trackArtFromAlbum', {
                 album:
diff --git a/src/content/dependencies/linkAnythingMan.js b/src/content/dependencies/linkAnythingMan.js
index e408c1b2..10ce7762 100644
--- a/src/content/dependencies/linkAnythingMan.js
+++ b/src/content/dependencies/linkAnythingMan.js
@@ -6,19 +6,15 @@ export default {
     'linkTrack',
   ],
 
-  query: (thing) => ({
-    referenceType: thing.constructor[Symbol.for('Thing.referenceType')],
-  }),
-
-  relations: (relation, query, thing) => ({
+  relations: (relation, thing) => ({
     link:
-      (query.referenceType === 'album'
+      (thing.isAlbum
         ? relation('linkAlbum', thing)
-     : query.referenceType === 'artwork'
+     : thing.isArtwork
         ? relation('linkArtwork', thing)
-     : query.referenceType === 'flash'
+     : thing.isFlash
         ? relation('linkFlash', thing)
-     : query.referenceType === 'track'
+     : thing.isTrack
         ? relation('linkTrack', thing)
         : null),
   }),
diff --git a/src/content/dependencies/linkArtwork.js b/src/content/dependencies/linkArtwork.js
index 8cd6f359..c10150d1 100644
--- a/src/content/dependencies/linkArtwork.js
+++ b/src/content/dependencies/linkArtwork.js
@@ -1,16 +1,11 @@
 export default {
   contentDependencies: ['linkAlbum', 'linkTrack'],
 
-  query: (artwork) => ({
-    referenceType:
-      artwork.thing.constructor[Symbol.for('Thing.referenceType')],
-  }),
-
-  relations: (relation, query, artwork) => ({
+  relations: (relation, artwork) => ({
     link:
-      (query.referenceType === 'album'
+      (artwork.thing.isAlbum
         ? relation('linkAlbum', artwork.thing)
-     : query.referenceType === 'track'
+     : artwork.thing.isTrack
         ? relation('linkTrack', artwork.thing)
         : null),
   }),
diff --git a/src/content/dependencies/linkReferencedArtworks.js b/src/content/dependencies/linkReferencedArtworks.js
index c456b808..f73a2ad3 100644
--- a/src/content/dependencies/linkReferencedArtworks.js
+++ b/src/content/dependencies/linkReferencedArtworks.js
@@ -1,21 +1,14 @@
-import Thing from '#thing';
-
 export default {
   contentDependencies: [
     'linkAlbumReferencedArtworks',
     'linkTrackReferencedArtworks',
   ],
 
-  query: (artwork) => ({
-    referenceType:
-      artwork.thing.constructor[Thing.referenceType],
-  }),
-
-  relations: (relation, query, artwork) => ({
+  relations: (relation, artwork) => ({
     link:
-      (query.referenceType === 'album'
+      (artwork.thing.isAlbum
         ? relation('linkAlbumReferencedArtworks', artwork.thing)
-     : query.referenceType === 'track'
+     : artwork.thing.isTrack
         ? relation('linkTrackReferencedArtworks', artwork.thing)
         : null),
   }),
diff --git a/src/content/dependencies/linkReferencingArtworks.js b/src/content/dependencies/linkReferencingArtworks.js
index 0cfca4db..6927f230 100644
--- a/src/content/dependencies/linkReferencingArtworks.js
+++ b/src/content/dependencies/linkReferencingArtworks.js
@@ -1,21 +1,14 @@
-import Thing from '#thing';
-
 export default {
   contentDependencies: [
     'linkAlbumReferencingArtworks',
     'linkTrackReferencingArtworks',
   ],
 
-  query: (artwork) => ({
-    referenceType:
-      artwork.thing.constructor[Thing.referenceType],
-  }),
-
-  relations: (relation, query, artwork) => ({
+  relations: (relation, artwork) => ({
     link:
-      (query.referenceType === 'album'
+      (artwork.thing.isAlbum
         ? relation('linkAlbumReferencingArtworks', artwork.thing)
-     : query.referenceType === 'track'
+     : artwork.thing.isTrack
         ? relation('linkTrackReferencingArtworks', artwork.thing)
         : null),
   }),