« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/common-util/wiki-data.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/common-util/wiki-data.js')
-rw-r--r--src/common-util/wiki-data.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/common-util/wiki-data.js b/src/common-util/wiki-data.js
index de34a807..c9c63db7 100644
--- a/src/common-util/wiki-data.js
+++ b/src/common-util/wiki-data.js
@@ -256,13 +256,18 @@ export function getArtistAvatar(artist, {to}) {
 // Used in multiple content functions for the artist info page,
 // because shared logic is torture oooooooooooooooo.
 export function chunkArtistTrackContributions(contributions) {
+  const date = contrib => contrib.date;
+
+  const album = contrib =>
+    (contrib.thing.isTrack
+      ? contrib.thing.album
+      : contrib.thing);
+
   return (
     // First chunk by (contribution) date and album.
     chunkByConditions(contributions, [
-      ({date: date1}, {date: date2}) =>
-        +date1 !== +date2,
-      ({thing: track1}, {thing: track2}) =>
-        track1.album !== track2.album,
+      (a, b) => +date(a) !== +date(b),
+      (a, b) => album(a) !== album(b),
     ]).map(contribs =>
         // Then, *within* the boundaries of the existing chunks,
         // chunk contributions to the same thing together.