perf: improve responsiveness

This commit is contained in:
plebeius.eth
2024-04-10 13:16:07 +02:00
parent b1fb9f9d0c
commit 62b83bf7ea
7 changed files with 36 additions and 12 deletions
+1 -1
View File
@@ -384,7 +384,7 @@
}
}
@media (min-width: 641px) {
@media (min-width: 640px) {
.postMobile {
display: none;
}
+7 -2
View File
@@ -8,6 +8,7 @@ import { getFormattedDate } from '../../lib/utils/time-utils';
import { isPostPageView } from '../../lib/utils/view-utils';
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
import useReplies from '../../hooks/use-replies';
import useWindowWidth from '../../hooks/use-window-width';
import styles from './post.module.css';
import Markdown from '../markdown';
import CommentMedia from '../comment-media';
@@ -417,11 +418,15 @@ const ReplyMobile = ({ reply, roles }: PostProps) => {
const Post = ({ post, showAllReplies = false }: PostProps) => {
const subplebbit = useSubplebbit({ subplebbitAddress: post?.subplebbitAddress });
const isMobile = useWindowWidth() < 640;
return (
<div className={styles.thread}>
<div className={styles.postContainer}>
<PostDesktop post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} />
<PostMobile post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} />
{isMobile ? (
<PostMobile post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} />
) : (
<PostDesktop post={post} roles={subplebbit?.roles} showAllReplies={showAllReplies} />
)}
</div>
</div>
);