From a7eda7e5840a4ddf568bbab8cfa8073a0f495ebf Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 21 Feb 2025 09:17:55 -0400 Subject: contentt, css: linkOtherReleaseOnArtistInfoPage: behaviorize --- src/common-util/wiki-data.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/common-util/wiki-data.js') diff --git a/src/common-util/wiki-data.js b/src/common-util/wiki-data.js index 24212e90..4bbef8ab 100644 --- a/src/common-util/wiki-data.js +++ b/src/common-util/wiki-data.js @@ -1,6 +1,6 @@ // Utility functions for interacting with wiki data. -import {accumulateSum, empty, unique} from './sugar.js'; +import {accumulateSum, chunkByConditions, empty, unique} from './sugar.js'; import {sortByDate} from './sort.js'; // This is a duplicate binding of filterMultipleArrays that's included purely @@ -192,6 +192,25 @@ export function getArtistAvatar(artist, {to}) { return to('media.artistAvatar', artist.directory, artist.avatarFileExtension); } +// Used in multiple content functions for the artist info page, +// because shared logic is torture oooooooooooooooo. +export function chunkArtistTrackContributions(contributions) { + return ( + // First chunk by (contribution) date and album. + chunkByConditions(contributions, [ + ({date: date1}, {date: date2}) => + +date1 !== +date2, + ({thing: track1}, {thing: track2}) => + track1.album !== track2.album, + ]).map(contribs => + // Then, *within* the boundaries of the existing chunks, + // chunk contributions to the same thing together. + chunkByConditions(contribs, [ + ({thing: thing1}, {thing: thing2}) => + thing1 !== thing2, + ]))); +} + // Big-ass homepage row functions export function getNewAdditions(numAlbums, {albumData}) { -- cgit 1.3.0-6-gf8a5