diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-21 09:17:55 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-03-02 08:24:14 -0400 |
commit | a7eda7e5840a4ddf568bbab8cfa8073a0f495ebf (patch) | |
tree | 23809c2853895f4d088a38166e0fbef57ccabc5e /src/common-util | |
parent | 0bed9ef3384f76421592d8f017d7deaa464fd859 (diff) |
contentt, css: linkOtherReleaseOnArtistInfoPage: behaviorize
Diffstat (limited to 'src/common-util')
-rw-r--r-- | src/common-util/wiki-data.js | 21 |
1 files changed, 20 insertions, 1 deletions
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}) { |