fix(pending post): settings were not shown correctly

This commit is contained in:
Tom (plebeius.eth)
2024-06-08 14:35:24 +02:00
parent 19222a66fe
commit ddd063fdef
2 changed files with 15 additions and 4 deletions
+3 -2
View File
@@ -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`
);
};
+12 -2
View File
@@ -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 <Post post={post} />;
return (
<>
{isInSettingsView && <SettingsModal />}
<Post post={post} showReplies={false} />;
</>
);
};
export default PendingPost;