« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateArtistInfoPage.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/content/dependencies/generateArtistInfoPage.js b/src/content/dependencies/generateArtistInfoPage.js
index 6956244b..1f6c66fc 100644
--- a/src/content/dependencies/generateArtistInfoPage.js
+++ b/src/content/dependencies/generateArtistInfoPage.js
@@ -30,7 +30,27 @@ export default {
 
   query(sprawl, artist) {
     return {
-      allTracks: unique([...artist.tracksAsArtist, ...artist.tracksAsContributor]),
+      // Even if an artist has served as both "artist" (compositional) and
+      // "contributor" (instruments, production, etc) on the same track, that
+      // track only counts as one unique contribution.
+      allTracks:
+        unique([...artist.tracksAsArtist, ...artist.tracksAsContributor]),
+
+      // Artworks are different, though. We intentionally duplicate album data
+      // objects when the artist has contributed some combination of cover art,
+      // wallpaper, and banner - these each count as a unique contribution.
+      allArtworks: [
+        ...artist.albumsAsCoverArtist,
+        ...artist.albumsAsWallpaperArtist,
+        ...artist.albumsAsBannerArtist,
+        ...artist.tracksAsCoverArtist,
+      ],
+
+      // Banners and wallpapers don't show up in the artist gallery page, only
+      // cover art.
+      hasGallery:
+        !empty(artist.albumsAsCoverArtist) ||
+        !empty(artist.tracksAsCoverArtist),
     };
   },
 
@@ -68,30 +88,17 @@ export default {
       tracks.groupInfo = relation('generateArtistGroupContributionsInfo', query.allTracks);
     }
 
-    if (
-      !empty(artist.albumsAsCoverArtist) ||
-      !empty(artist.albumsAsWallpaperArtist) ||
-      !empty(artist.albumsAsBannerArtist) ||
-      !empty(artist.tracksAsCoverArtist)
-    ) {
+    if (!empty(query.allArtworks)) {
       const artworks = sections.artworks = {};
       artworks.heading = relation('generateContentHeading');
       artworks.list = relation('generateArtistInfoPageArtworksChunkedList', artist);
+      artworks.groupInfo =
+        relation('generateArtistGroupContributionsInfo', query.allArtworks);
 
-      if (!empty(artist.albumsAsCoverArtist) || !empty(artist.tracksAsCoverArtist)) {
+      if (query.hasGallery) {
         artworks.artistGalleryLink =
           relation('linkArtistGallery', artist);
       }
-
-      // We intentionally duplicate album data objects when the artist has contributed
-      // at least two of cover art / wallpaper / banner! These each count as one.
-      artworks.groupInfo =
-        relation('generateArtistGroupContributionsInfo', [
-          ...artist.albumsAsCoverArtist,
-          ...artist.albumsAsWallpaperArtist,
-          ...artist.albumsAsBannerArtist,
-          ...artist.tracksAsCoverArtist,
-        ]);
     }
 
     if (sprawl.enableFlashesAndGames && !empty(artist.flashesAsContributor)) {