From fc2b48b652bd0b05004ec38586d936a83d644abb Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Sat, 27 Apr 2024 14:48:06 +0200 Subject: [PATCH] Update post.tsx --- src/components/post/post.tsx | 41 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index 0d38f61d..ff426650 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -5,7 +5,7 @@ import { Role, useSubplebbit } from '@plebbit/plebbit-react-hooks'; import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; import { getCommentMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils'; import { getFormattedDate } from '../../lib/utils/time-utils'; -import { isPostPageView, isPendingPostView } from '../../lib/utils/view-utils'; +import { isPostPageView } from '../../lib/utils/view-utils'; import useCountLinksInReplies from '../../hooks/use-count-links-in-replies'; import useReplies from '../../hooks/use-replies'; import useStateString from '../../hooks/use-state-string'; @@ -35,7 +35,6 @@ const PostDesktop = ({ post, roles, showAllReplies }: PostProps) => { const params = useParams(); const location = useLocation(); const isInPostPage = isPostPageView(location.pathname, params); - const isInPendingPostPage = isPendingPostView(location.pathname, params); const displayTitle = title && title.length > 75 ? title?.slice(0, 75) + '...' : title; const displayContent = content && !isInPostPage && content.length > 1000 ? content?.slice(0, 1000) + '(...)' : content; @@ -125,15 +124,10 @@ const PostDesktop = ({ post, roles, showAllReplies }: PostProps) => { {!(isDescription || isRules) && ( - isInPendingPostPage && e.preventDefault()} - > + !cid && e.preventDefault()}> c/ - {isInPendingPostPage ? ( + {!cid ? ( {state === 'failed' ? 'Failed' : 'Pending'} ) : ( @@ -343,7 +337,6 @@ const PostMobile = ({ post, roles, showAllReplies }: PostProps) => { const params = useParams(); const location = useLocation(); const isInPostPage = isPostPageView(location.pathname, params); - const isInPendingPostPage = isPendingPostView(location.pathname, params); const linkCount = useCountLinksInReplies(post); const displayTitle = title && title.length > 30 ? title?.slice(0, 30) + '(...)' : title; @@ -368,7 +361,7 @@ const PostMobile = ({ post, roles, showAllReplies }: PostProps) => { ... - + {displayName || 'Anonymous'} {authorRole && ` ## Board ${authorRole}`}{' '} @@ -394,15 +387,10 @@ const PostMobile = ({ post, roles, showAllReplies }: PostProps) => { {getFormattedDate(timestamp)}{' '} {!(isDescription || isRules) && ( - isInPendingPostPage && e.preventDefault()} - > + !cid && e.preventDefault()}> c/ - {isInPendingPostPage ? ( + {!cid ? ( {state === 'failed' ? 'Failed' : 'Pending'} ) : ( @@ -462,7 +450,7 @@ const PostMobile = ({ post, roles, showAllReplies }: PostProps) => { const ReplyMobile = ({ reply, roles }: PostProps) => { const { t } = useTranslation(); - const { author, content, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, subplebbitAddress, timestamp } = reply || {}; + const { author, content, cid, link, linkHeight, linkWidth, parentCid, pinned, postCid, shortCid, state, subplebbitAddress, timestamp } = reply || {}; const { address, displayName, shortAddress } = author || {}; const authorRole = roles?.[address]?.role; @@ -491,8 +479,19 @@ const ReplyMobile = ({ reply, roles }: PostProps) => { )} - {getFormattedDate(timestamp)} c/ - {shortCid} + {getFormattedDate(timestamp)}{' '} + + !cid && e.preventDefault()}> + c/ + + + {!cid ? ( + {state === 'failed' ? 'Failed' : 'Pending'} + ) : ( + + {shortCid} + + )} {(hasThumbnail || link) && (