« get me outta code hell

sort: sortContributionsChronologically: fix non-mutating - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-10 19:12:22 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-12 17:26:45 -0300
commit5d5d47602ec3b3778c16717957528e697d43dfef (patch)
tree5decc82a776d7fc1341f97ebe7c002823251e284
parent719172278b854ca2b63a5a46a6f115a3b3057961 (diff)
sort: sortContributionsChronologically: fix non-mutating
-rw-r--r--src/util/sort.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/util/sort.js b/src/util/sort.js
index 8a096dc1..ea1e024a 100644
--- a/src/util/sort.js
+++ b/src/util/sort.js
@@ -429,5 +429,10 @@ export function sortContributionsChronologically(data, sortThings, {
 
   sortByDate(contribs, {latestFirst});
 
-  return contribs;
+  // We're not actually operating on the original data array at any point,
+  // so since this is meant to be a mutating function like any other, splice
+  // the sorted contribs into the original array.
+  data.splice(0, data.length, ...contribs);
+
+  return data;
 }