« get me outta code hell

sort: sortArtworksChronologically - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/common-util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-12 17:54:40 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-12 17:54:40 -0300
commita83b5c4aebb058f603a4553fe7db99b34b18760e (patch)
treea7c726e0aca4a9f0f467007ed84658aa617c5d0c /src/common-util
parent27f4be16d385aab19f9b9f85a0a1a4822aecde38 (diff)
sort: sortArtworksChronologically
Diffstat (limited to 'src/common-util')
-rw-r--r--src/common-util/sort.js16
1 files changed, 16 insertions, 0 deletions
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,