From ddd063fdef245d6a76637ce7de83f56f753aca81 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sat, 8 Jun 2024 14:35:24 +0200 Subject: [PATCH] fix(pending post): settings were not shown correctly --- src/lib/utils/view-utils.ts | 5 +++-- src/views/pending-post/pending-post.tsx | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/utils/view-utils.ts b/src/lib/utils/view-utils.ts index 080d19ec..a990c9c5 100644 --- a/src/lib/utils/view-utils.ts +++ b/src/lib/utils/view-utils.ts @@ -45,12 +45,13 @@ export const isRulesView = (pathname: string, params: ParamsType): boolean => { }; export const isSettingsView = (pathname: string, params: ParamsType): boolean => { - const { subplebbitAddress, commentCid } = params; + const { accountCommentIndex, commentCid, subplebbitAddress } = params; const decodedPathname = decodeURIComponent(pathname); return ( decodedPathname === `/p/${subplebbitAddress}/c/${commentCid}/settings` || decodedPathname === `/p/${subplebbitAddress}/description/settings` || - decodedPathname === `/p/${subplebbitAddress}/rules/settings` + decodedPathname === `/p/${subplebbitAddress}/rules/settings` || + decodedPathname === `/profile/${accountCommentIndex}/settings` ); }; diff --git a/src/views/pending-post/pending-post.tsx b/src/views/pending-post/pending-post.tsx index 0aab5e3b..4b25fd9c 100644 --- a/src/views/pending-post/pending-post.tsx +++ b/src/views/pending-post/pending-post.tsx @@ -1,13 +1,18 @@ import { useEffect } from 'react'; -import { useNavigate, useParams } from 'react-router-dom'; +import { useLocation, useNavigate, useParams } from 'react-router-dom'; import { useAccountComment } from '@plebbit/plebbit-react-hooks'; +import { isSettingsView } from '../../lib/utils/view-utils'; import Post from '../../components/post'; +import SettingsModal from '../../components/settings-modal'; const PendingPost = () => { const { accountCommentIndex } = useParams<{ accountCommentIndex?: string }>(); const commentIndex = accountCommentIndex ? parseInt(accountCommentIndex) : undefined; const post = useAccountComment({ commentIndex }); const navigate = useNavigate(); + const location = useLocation(); + const params = useParams(); + const isInSettingsView = isSettingsView(location.pathname, params); useEffect(() => window.scrollTo(0, 0), []); @@ -17,7 +22,12 @@ const PendingPost = () => { } }, [post, navigate]); - return ; + return ( + <> + {isInSettingsView && } + ; + + ); }; export default PendingPost;