From 52dded85ed63f3a388fd90bb35412038c3b79146 Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Sun, 24 Jul 2022 11:51:42 -0400
Subject: quick fix for routes refreshing constantly

---
 frontend/src/router-hook.tsx | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'frontend/src/router-hook.tsx')

diff --git a/frontend/src/router-hook.tsx b/frontend/src/router-hook.tsx
index e318930e..4e23658e 100644
--- a/frontend/src/router-hook.tsx
+++ b/frontend/src/router-hook.tsx
@@ -41,11 +41,16 @@ class RouterHook extends Logger {
     const DeckyWrapper = ({ children }: { children: ReactElement }) => {
       const { routes } = useDeckyRouterState();
 
-      const routerIndex = children.props.children[0].props.children.length;
+      let routerIndex = children.props.children[0].props.children.length;
       if (
-        !children.props.children[0].props.children[routerIndex]?.length ||
-        children.props.children[0].props.children[routerIndex].length !== routes.size
+        !children.props.children[0].props.children[routerIndex - 1]?.length ||
+        children.props.children[0].props.children[routerIndex - 1]?.length !== routes.size
       ) {
+        if (
+          children.props.children[0].props.children[routerIndex - 1]?.length &&
+          children.props.children[0].props.children[routerIndex - 1].length !== routes.size
+        )
+          routerIndex--;
         const newRouterArray: ReactElement[] = [];
         routes.forEach(({ component, props }, path) => {
           newRouterArray.push(
-- 
cgit v1.2.3

