From 9db7b9db4538698cc7d220ec9e696701cf983fc1 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Thu, 20 Feb 2025 22:02:01 +0100 Subject: [PATCH] revert route validation, redirection should be handled by each view component if needed --- src/app.tsx | 73 ++++++++++++++++++----------------------------------- 1 file changed, 24 insertions(+), 49 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index aed92d33..54b8333e 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,11 +1,10 @@ import { useEffect, useState } from 'react'; import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom'; -import { useAccountComment, useAccountComments } from '@plebbit/plebbit-react-hooks'; +import { useAccountComment } from '@plebbit/plebbit-react-hooks'; import { initSnow, removeSnow } from './lib/snow'; import { isAllView, isSubscriptionsView } from './lib/utils/view-utils'; import useIsMobile from './hooks/use-is-mobile'; import useTheme from './hooks/use-theme'; -import useTimeFilter from './hooks/use-time-filter'; import styles from './app.module.css'; import Board from './views/board'; import Catalog from './views/catalog'; @@ -22,29 +21,6 @@ import SubplebbitStats from './components/subplebbit-stats'; import TopBar from './components/topbar'; import useSpecialThemeStore from './stores/use-special-theme-store'; -const ValidateRouteParams = () => { - const { accountCommentIndex, timeFilterName } = useParams(); - const { timeFilterNames, lastVisitTimeFilterName } = useTimeFilter(); - const { accountComments } = useAccountComments(); - - const isValidAccountCommentIndex = - !accountCommentIndex || - (!isNaN(parseInt(accountCommentIndex)) && - parseInt(accountCommentIndex) >= 0 && - accountComments?.length > 0 && - parseInt(accountCommentIndex) < accountComments.length); - - const isDynamicTimeFilter = (filter: string) => /^\d+[hdwmy]$/.test(filter); - const isTimeFilterNameValid = - !timeFilterName || timeFilterNames.includes(timeFilterName as any) || timeFilterName === lastVisitTimeFilterName || isDynamicTimeFilter(timeFilterName); - - if (!isValidAccountCommentIndex || !isTimeFilterNameValid) { - return ; - } - - return ; -}; - const BoardLayout = () => { const { accountCommentIndex, subplebbitAddress } = useParams(); const location = useLocation(); @@ -128,35 +104,34 @@ const App = () => { } /> } /> } /> - }> - }> - } /> - } /> - } /> - } /> + }> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> - } /> - } /> - + } /> + } /> + } />