Files
5chan/src/components/post/post.tsx
T

34 lines
1.0 KiB
TypeScript
Raw Normal View History

import { Role, useSubplebbit } from '@plebbit/plebbit-react-hooks';
2024-04-10 13:16:07 +02:00
import useWindowWidth from '../../hooks/use-window-width';
2024-03-29 13:54:11 +01:00
import styles from './post.module.css';
import PostDesktop from './post-desktop';
import PostMobile from './post-mobile';
2024-03-29 13:54:11 +01:00
export interface PostProps {
2024-04-08 16:03:32 +02:00
index?: number;
post?: any;
reply?: any;
roles?: Role[];
showAllReplies?: boolean;
2024-04-28 20:08:41 +02:00
openReplyModal?: (cid: string) => void;
2024-04-08 16:03:32 +02:00
}
const Post = ({ post, showAllReplies = false, openReplyModal }: PostProps) => {
2024-04-08 16:03:32 +02:00
const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress });
2024-04-10 13:16:07 +02:00
const isMobile = useWindowWidth() < 640;
2024-04-28 20:08:41 +02:00
return (
<div className={styles.thread}>
<div className={styles.postContainer}>
2024-04-10 13:16:07 +02:00
{isMobile ? (
<PostMobile post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} openReplyModal={openReplyModal} />
2024-04-10 13:16:07 +02:00
) : (
<PostDesktop post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} openReplyModal={openReplyModal} />
2024-04-10 13:16:07 +02:00
)}
</div>
</div>
);
};
2024-03-22 15:31:02 +01:00
export default Post;