feat(multisubs): add subplebbit address in post info

This commit is contained in:
plebeius.eth
2024-05-17 15:29:03 +02:00
parent 07af3187c6
commit 82fe238979
5 changed files with 83 additions and 63 deletions
+2 -25
View File
@@ -1,6 +1,4 @@
import { useLocation, useParams } from 'react-router-dom';
import { Role, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { isPendingPostView, isPostPageView } from '../../lib/utils/view-utils';
import useWindowWidth from '../../hooks/use-window-width';
import styles from './post.module.css';
import PostDesktop from './post-desktop';
@@ -8,8 +6,6 @@ import PostMobile from './post-mobile';
export interface PostProps {
index?: number;
isInPostPage?: boolean;
isPendingPostPage?: boolean;
post?: any;
reply?: any;
roles?: Role[];
@@ -21,32 +17,13 @@ const Post = ({ post, showAllReplies = false, openReplyModal }: PostProps) => {
const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress });
const isMobile = useWindowWidth() < 640;
const params = useParams();
const location = useLocation();
const isInPostPage = isPostPageView(location.pathname, params);
const isPendingPostPage = isPendingPostView(location.pathname, params);
return (
<div className={styles.thread}>
<div className={styles.postContainer}>
{isMobile ? (
<PostMobile
isInPostPage={isInPostPage}
isPendingPostPage={isPendingPostPage}
post={post}
roles={subplebbit?.roles}
showAllReplies={showAllReplies}
openReplyModal={openReplyModal}
/>
<PostMobile post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} openReplyModal={openReplyModal} />
) : (
<PostDesktop
isInPostPage={isInPostPage}
isPendingPostPage={isPendingPostPage}
post={post}
roles={subplebbit?.roles}
showAllReplies={showAllReplies}
openReplyModal={openReplyModal}
/>
<PostDesktop post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} openReplyModal={openReplyModal} />
)}
</div>
</div>