From e960f791b98063da7f2b3bde40df41f5e8b80712 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Thu, 4 Apr 2024 11:41:17 +0200 Subject: [PATCH] feat(post page): scroll to top, show full content, no hide thread --- src/components/post/post.tsx | 28 ++++++++++++++++------------ src/views/post-page/post-page.tsx | 5 +++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index 4b3bad81..d43a696f 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -106,8 +106,11 @@ const PostDesktop = ({ post, showAllReplies }: { post: Comment; showAllReplies: const { t } = useTranslation(); const { author, cid, content, link, linkHeight, linkWidth, locked, pinned, postCid, replyCount, shortCid, subplebbitAddress, timestamp, title } = post || {}; const { displayName, shortAddress } = author || {}; + + const isInPostPage = isPostPageView(useLocation().pathname, useParams()); + const displayTitle = title && title.length > 75 ? title?.slice(0, 75) + '...' : title; - const displayContent = content && content.length > 1000 ? content?.slice(0, 1000) + '(...)' : content; + const displayContent = content && !isInPostPage && content.length > 1000 ? content?.slice(0, 1000) + '(...)' : content; const commentMediaInfo = getCommentMediaInfoMemoized(post); const hasThumbnail = getHasThumbnail(commentMediaInfo, link); @@ -124,9 +127,11 @@ const PostDesktop = ({ post, showAllReplies }: { post: Comment; showAllReplies:

- - - + {!isInPostPage && ( + + + + )} {commentMediaInfo?.url && (
@@ -198,7 +203,7 @@ const PostDesktop = ({ post, showAllReplies }: { post: Comment; showAllReplies: {content && (
- {content.length > 1000 && ( + {content.length > 1000 && !isInPostPage && (
Comment too long. Click here to view the full text. @@ -206,7 +211,7 @@ const PostDesktop = ({ post, showAllReplies }: { post: Comment; showAllReplies: )}
)} - {(replies.length > 5 || pinned) && ( + {(replies.length > 5 || pinned) && !isInPostPage && ( @@ -215,8 +220,9 @@ const PostDesktop = ({ post, showAllReplies }: { post: Comment; showAllReplies: Click here to view. )} - {!pinned && - replies?.slice(0, showAllReplies ? replies.length : 5).map((reply, index) => ( + {!(pinned && !isInPostPage) && + replies && + replies.slice(0, showAllReplies ? replies.length : 5).map((reply, index) => (
@@ -294,9 +300,7 @@ const PostMobile = ({ post, showAllReplies }: { post: Comment; showAllReplies: b const replies = useReplies(post); - const location = useLocation(); - const params = useParams(); - const isInPostPage = isPostPageView(location.pathname, params); + const isInPostPage = isPostPageView(useLocation().pathname, useParams()); return (
@@ -339,7 +343,7 @@ const PostMobile = ({ post, showAllReplies }: { post: Comment; showAllReplies: b {content && (
- {content.length > 1000 && ( + {content.length > 1000 && !isInPostPage && (
Comment too long. Click here to view the full text. diff --git a/src/views/post-page/post-page.tsx b/src/views/post-page/post-page.tsx index 56be8b03..d31cbddc 100644 --- a/src/views/post-page/post-page.tsx +++ b/src/views/post-page/post-page.tsx @@ -1,3 +1,4 @@ +import { useEffect } from 'react'; import { useComment } from '@plebbit/plebbit-react-hooks'; import { useParams } from 'react-router-dom'; import Post from '../../components/post/post'; @@ -9,6 +10,10 @@ const PostPage = () => { const post = useComment({ commentCid }); + useEffect(() => { + window.scrollTo(0, 0); + }, []); + return (