From 0f6b9225165983986771a712787c30f5a5215c8d Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Sat, 31 Aug 2024 14:57:11 +0200 Subject: [PATCH] fix(post): reply backlink didn't appear in post info immediately after replying to it --- src/components/post-desktop/post-desktop.tsx | 6 +++-- src/components/post-mobile/post-mobile.tsx | 8 +++--- .../reply-quote-preview.tsx | 25 +++++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 395dfc81..2b77a3f6 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -199,10 +199,12 @@ const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: )} - {replyCount > 0 && + {cid && parentCid && replies && - replies.map((reply: Comment, index: number) => reply?.parentCid === cid && )} + replies.map( + (reply: Comment, index: number) => reply?.parentCid === cid && reply?.cid && , + )} ); }; diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index d89ebc68..b5280bba 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -172,15 +172,17 @@ const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: P }; const ReplyBacklinks = ({ post }: PostProps) => { - const { cid, parentCid, replyCount } = post || {}; + const { cid, parentCid } = post || {}; const replies = useReplies(post); return ( - replyCount > 0 && + cid && parentCid && replies && (
- {replies.map((reply: Comment, index: number) => reply?.parentCid === cid && )} + {replies.map( + (reply: Comment, index: number) => reply?.parentCid === cid && reply?.cid && , + )}
) ); diff --git a/src/components/reply-quote-preview/reply-quote-preview.tsx b/src/components/reply-quote-preview/reply-quote-preview.tsx index 6df42524..5e5d5b39 100644 --- a/src/components/reply-quote-preview/reply-quote-preview.tsx +++ b/src/components/reply-quote-preview/reply-quote-preview.tsx @@ -139,7 +139,7 @@ const DesktopQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, i onMouseOver={() => handleMouseOver(quotelinkReply?.cid)} onMouseLeave={() => handleMouseLeave(quotelinkReply?.cid)} > - {`c/${quotelinkReply?.shortCid}`} + {quotelinkReply?.shortCid && `c/${quotelinkReply?.shortCid}`} {quotelinkReply?.author?.address === account?.author?.address && ' (You)'}
@@ -200,11 +200,13 @@ const MobileQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, is onMouseOver={() => handleMouseOver(backlinkReply?.cid)} onMouseLeave={() => handleMouseLeave(backlinkReply?.cid)} > - c/{backlinkReply?.shortCid}{' '} + {backlinkReply?.shortCid && `c/${backlinkReply?.shortCid}`} - - # - + {backlinkReply?.shortCid && ( + + # + + )} {hoveredCid === backlinkReply?.cid && outOfViewCid === backlinkReply?.cid && createPortal( @@ -226,14 +228,15 @@ const MobileQuotePreview = ({ backlinkReply, quotelinkReply, isBacklinkReply, is onMouseOver={() => handleMouseOver(quotelinkReply?.cid)} onMouseLeave={() => handleMouseLeave(quotelinkReply?.cid)} > - c/{quotelinkReply?.shortCid} + {quotelinkReply?.shortCid && `c/${quotelinkReply?.shortCid}`} {quotelinkReply?.author?.address === account?.author?.address && ' (You)'} - - {' '} - # - -
+ {quotelinkReply?.shortCid && ( + + {' '} + # + + )} {hoveredCid === quotelinkReply?.cid && outOfViewCid === quotelinkReply?.cid && createPortal(