mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(pending post): settings were not shown correctly
This commit is contained in:
@@ -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`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user