From 3e33f501c95048f99e235eea9819fb9be1122bfc Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 6 Nov 2023 12:21:09 +0100 Subject: [PATCH] feat(use-current-view): add isPendingView --- src/hooks/use-current-view.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hooks/use-current-view.ts b/src/hooks/use-current-view.ts index 684c743e..22768689 100644 --- a/src/hooks/use-current-view.ts +++ b/src/hooks/use-current-view.ts @@ -2,31 +2,34 @@ import { useLocation, useParams } from 'react-router-dom'; type CurrentView = { isHomeView: boolean; - isSubplebbitView: boolean; + isPendingView: boolean; isPostView: boolean; isSubmitView: boolean; + isSubplebbitView: boolean; isSubplebbitSubmitView: boolean; }; type ParamsType = { - subplebbitAddress?: string; + accountCommentIndex?: string; commentCid?: string; + subplebbitAddress?: string; }; const sortTypes = ['/hot', '/new', '/active', '/controversialAll', '/topAll']; const useCurrentView = (): CurrentView => { const location = useLocation(); - const { subplebbitAddress, commentCid } = useParams(); + const { accountCommentIndex, commentCid, subplebbitAddress } = useParams(); const pathname = location.pathname; const isHomeView = pathname === `/` || sortTypes.includes(pathname); - const isSubplebbitView = subplebbitAddress ? pathname.startsWith(`/p/${subplebbitAddress}`) : false; + const isPendingView = pathname === `/profile/${accountCommentIndex}`; const isPostView = subplebbitAddress && commentCid ? pathname.startsWith(`/p/${subplebbitAddress}/c/${commentCid}`) : false; const isSubmitView = pathname === `/submit`; + const isSubplebbitView = subplebbitAddress ? pathname.startsWith(`/p/${subplebbitAddress}`) : false; const isSubplebbitSubmitView = subplebbitAddress ? pathname === `/p/${subplebbitAddress}/submit` : false; - return { isHomeView, isSubplebbitView, isPostView, isSubmitView, isSubplebbitSubmitView }; + return { isHomeView, isSubplebbitView, isPendingView, isPostView, isSubmitView, isSubplebbitSubmitView }; }; export default useCurrentView;