« get me outta code hell

data: use flash act directory for better determinism - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/wiki-data.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-11 14:49:43 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-11 14:49:43 -0300
commite842ce93e6405334b6ef475ec1db41e051cfd2b5 (patch)
treea745c6330a0182de1c6323cea9f70ff8bf877d39 /src/util/wiki-data.js
parent3a871cf43a11b87392d26320c736b516925da684 (diff)
data: use flash act directory for better determinism
Diffstat (limited to 'src/util/wiki-data.js')
-rw-r--r--src/util/wiki-data.js15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index ac652b2..0790ae9 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -610,20 +610,9 @@ export function sortFlashesChronologically(data, {
   latestFirst = false,
   getDate,
 } = {}) {
-  // Flash acts don't actually have any identifying properties because they
-  // don't have dedicated pages (yet), so don't have a directory. Make up a
-  // fake key identifying them so flashes can be grouped together.
-  const flashActs = new Set(data.map(flash => flash.act));
-  const flashActIdentifiers = new Map();
-
-  let counter = 0;
-  for (const act of flashActs) {
-    flashActIdentifiers.set(act, ++counter);
-  }
-
   // Group flashes by act...
-  data.sort((a, b) => {
-    return flashActIdentifiers.get(a.act) - flashActIdentifiers.get(b.act);
+  sortByDirectory(data, {
+    getDirectory: flash => flash.act.directory,
   });
 
   // Sort flashes by position in act...