From a83b5c4aebb058f603a4553fe7db99b34b18760e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 12 Apr 2025 17:54:40 -0300 Subject: sort: sortArtworksChronologically --- src/common-util/sort.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/common-util/sort.js') diff --git a/src/common-util/sort.js b/src/common-util/sort.js index 3cfe8f70..d93d94c1 100644 --- a/src/common-util/sort.js +++ b/src/common-util/sort.js @@ -389,6 +389,22 @@ export function sortAlbumsTracksChronologically(data, { return data; } +export function sortArtworksChronologically(data, { + latestFirst = false, +} = {}) { + // Artworks conveniently describe their things as artwork.thing, so they + // work in sortEntryThingPairs. (Yes, this is just assuming the artworks + // are only for albums and tracks... sorry... TODO...) + sortEntryThingPairs(data, things => + sortAlbumsTracksChronologically(things, {latestFirst})); + + // Artworks' own dates always matter before however the thing places itself, + // and accommodate per-thing properties like coverArtDate anyway. + sortByDate(data, {latestFirst}); + + return data; +} + export function sortFlashesChronologically(data, { latestFirst = false, getDate, -- cgit 1.3.0-6-gf8a5