« 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/generateTrackChronologyLinks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateTrackChronologyLinks.js')
-rw-r--r--src/content/dependencies/generateTrackChronologyLinks.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js
index 5f6b0771..f9ad6299 100644
--- a/src/content/dependencies/generateTrackChronologyLinks.js
+++ b/src/content/dependencies/generateTrackChronologyLinks.js
@@ -38,9 +38,11 @@ export default {
 
               const things =
                 ([
-                  ...artist.tracksAsArtist,
-                  ...artist.tracksAsContributor,
-                ]).filter(getDate)
+                  artist.trackArtistContributions,
+                  artist.trackContributorContributions,
+                ]).flat()
+                  .map(({thing}) => thing)
+                  .filter(getDate)
                   .filter(albumFilter);
 
               return sortAlbumsTracksChronologically(things, {getDate});
@@ -61,11 +63,20 @@ export default {
             getThings(artist) {
               const getDate = thing => thing.coverArtDate ?? thing.date;
 
+              // Album artwork isn't part of cover artist chronology scoped to
+              // even the same album - we use this list to show "nth track art".
+              const applicableContributions =
+                (album
+                  ? artist.trackCoverArtistContributions
+                  : ([
+                      artist.albumCoverArtistContributions,
+                      artist.trackCoverArtistContributions,
+                    ]).flat());
+
               const things =
-                ([
-                  ...artist.albumsAsCoverArtist,
-                  ...artist.tracksAsCoverArtist,
-                ]).filter(getDate)
+                applicableContributions
+                  .map(({thing}) => thing)
+                  .filter(getDate)
                   .filter(albumFilter);
 
               return sortAlbumsTracksChronologically(things, {getDate});