« get me outta code hell

content: generateFlashActSidebar: mostly don't hard-code sides - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-03 13:55:10 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-03 13:55:10 -0300
commitfc575fbbb4809f15f819e7bd426126f9e6eadbf4 (patch)
tree87770624cb8ef8f7e7be786fe3931d6ed2d2fe61 /src/content/dependencies
parent26e991202ba6978e29a939212f4055ec3bd5dcee (diff)
content: generateFlashActSidebar: mostly don't hard-code sides
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateFlashActSidebar.js72
1 files changed, 12 insertions, 60 deletions
diff --git a/src/content/dependencies/generateFlashActSidebar.js b/src/content/dependencies/generateFlashActSidebar.js
index 0bbfa1f8..f7733d53 100644
--- a/src/content/dependencies/generateFlashActSidebar.js
+++ b/src/content/dependencies/generateFlashActSidebar.js
@@ -1,5 +1,4 @@
-import find from '#find';
-import {filterMultipleArrays, stitchArrays} from '#sugar';
+import {stitchArrays} from '#sugar';
 
 export default {
   contentDependencies: ['linkFlash', 'linkFlashAct', 'linkFlashIndex'],
@@ -7,67 +6,20 @@ export default {
 
   // So help me Gog, the flash sidebar is heavily hard-coded.
 
-  sprawl: ({flashActData}) => ({flashActData}),
+  sprawl: ({flashActData, flashSideData}) => ({flashActData, flashSideData}),
 
   query(sprawl, act, flash) {
-    const findFlashAct = directory =>
-      find.flashAct(directory, sprawl.flashActData, {mode: 'quiet'});
-
-    const homestuckSide1 = findFlashAct('flash-act:a1');
-
-    const sideFirstActs = [
-      sprawl.flashActData[0],
-      findFlashAct('flash-act:a6a1'),
-      findFlashAct('flash-act:hiveswap'),
-      findFlashAct('flash-act:cool-and-new-web-comic'),
-      findFlashAct('flash-act:sunday-night-strifin'),
-    ];
-
-    const sideNames = [
-      (homestuckSide1
-        ? `Side 1 (Acts 1-5)`
-        : `All flashes & games`),
-      `Side 2 (Acts 6-7)`,
-      `Additional Canon`,
-      `Fan Adventures`,
-      `Fan Games & More`,
-    ];
-
-    const sideColors = [
-      (homestuckSide1
-        ? '#4ac925'
-        : null),
-      '#3796c6',
-      '#f2a400',
-      '#c466ff',
-      '#32c7fe',
-    ];
-
-    filterMultipleArrays(sideFirstActs, sideNames, sideColors,
-      firstAct => firstAct);
-
-    const sideFirstActIndexes =
-      sideFirstActs
-        .map(act => sprawl.flashActData.indexOf(act));
-
-    const actSideIndexes =
-      sprawl.flashActData
-        .map((act, actIndex) => actIndex)
-        .map(actIndex =>
-          sideFirstActIndexes
-            .findIndex((firstActIndex, i) =>
-              i === sideFirstActs.length - 1 ||
-                firstActIndex <= actIndex &&
-                sideFirstActIndexes[i + 1] > actIndex));
+    const sideNames =
+      sprawl.flashSideData
+        .map(side => side.name);
+
+    const sideColors =
+      sprawl.flashSideData
+        .map(side => side.color);
 
     const sideActs =
-      sideNames
-        .map((name, sideIndex) =>
-          stitchArrays({
-            act: sprawl.flashActData,
-            actSideIndex: actSideIndexes,
-          }).filter(({actSideIndex}) => actSideIndex === sideIndex)
-            .map(({act}) => act));
+      sprawl.flashSideData
+        .map(side => side.acts);
 
     const currentActFlashes =
       act.flashes;
@@ -76,7 +28,7 @@ export default {
       currentActFlashes.indexOf(flash);
 
     const currentSideIndex =
-      actSideIndexes[sprawl.flashActData.indexOf(act)];
+      sideActs.findIndex(acts => acts.includes(act));
 
     const currentSideActs =
       sideActs[currentSideIndex];