From d862550132d10131f3cb157a6997547df1832e45 Mon Sep 17 00:00:00 2001 From: plebeius Date: Wed, 11 Feb 2026 18:52:10 +0800 Subject: [PATCH] fix(post): render OP backlinks from replies quoting OP --- src/components/post-desktop/post-desktop.tsx | 22 ++++++----------- src/components/post-mobile/post-mobile.tsx | 25 +++++++------------- src/views/post/post.tsx | 1 - 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index b24e76ca..0976c446 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -76,7 +76,6 @@ const PostInfo = ({ onApprove, onReject, quotedByMap, - cidToReply, }: PostProps) => { const { t } = useTranslation(); const { author, cid, deleted, locked, pinned, parentCid, postCid, reason, removed, state, subplebbitAddress, timestamp } = post || {}; @@ -442,11 +441,12 @@ const PostInfo = ({ {cid && !parentCid && isInPostPageView && - cidToReply && - [...new Set((post?.quotedCids || []) as string[])].map((quotedCid) => { - const reply = cidToReply.get(quotedCid); - return reply?.cid && !(reply.deleted || reply.removed) && ; - })} + quotedByMap + ?.get(cid) + ?.map( + (reply: Comment) => + reply?.cid && !(reply?.deleted || reply?.removed) && , + )} ); @@ -690,14 +690,6 @@ const PostDesktop = ({ return map; }, [filteredReplies, numberToCid]); - const cidToReply = useMemo(() => { - const map = new Map(); - for (const reply of filteredReplies) { - if (reply.cid) map.set(reply.cid, reply); - } - return map; - }, [filteredReplies]); - // Virtuoso scroll position management for infinite replies const virtuosoRef = useRef(null); const virtuosoStateKey = `replies-desktop-${cid}`; @@ -786,7 +778,7 @@ const PostDesktop = ({ isPublishing={isPublishing} onApprove={onApprove} onReject={onReject} - cidToReply={cidToReply} + quotedByMap={quotedByMap} /> {!isHidden && !content && !(deleted || removed) &&
} {!isHidden && } diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index 19b6f757..358699c0 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -380,7 +380,7 @@ const PostMediaContent = ({ post, link }: { post: any; link: string }) => { ); }; -const ReplyBacklinks = ({ post, quotedByMap, cidToReply, isInPostPageView }: PostProps) => { +const ReplyBacklinks = ({ post, quotedByMap, isInPostPageView }: PostProps) => { const { cid, parentCid } = post || {}; const { replies } = useReplies({ comment: post, flat: true, accountComments: { newerThan: Infinity } }); @@ -388,13 +388,12 @@ const ReplyBacklinks = ({ post, quotedByMap, cidToReply, isInPostPageView }: Pos cid && !parentCid && isInPostPageView && - cidToReply && - post?.quotedCids?.length && - [...new Set(post.quotedCids as string[])] - .map((quotedCid) => { - const reply = cidToReply.get(quotedCid); - return reply?.cid && !(reply.deleted || reply.removed) && ; - }) + quotedByMap + ?.get(cid) + ?.map( + (reply: Comment) => + reply?.cid && !(reply?.deleted || reply?.removed) && , + ) .filter(Boolean); const replyBacklinks = cid && parentCid && ((replies?.length || 0) > 0 || quotedByMap?.get(cid)?.length) && ( @@ -534,14 +533,6 @@ const PostMobile = ({ return map; }, [filteredReplies, numberToCid]); - const cidToReply = useMemo(() => { - const map = new Map(); - for (const reply of filteredReplies) { - if (reply.cid) map.set(reply.cid, reply); - } - return map; - }, [filteredReplies]); - // Virtuoso scroll position management for infinite replies const virtuosoRef = useRef(null); const virtuosoStateKey = `replies-mobile-${cid}`; @@ -610,7 +601,7 @@ const PostMobile = ({ {shouldShowSnow() && } - +
{!isInPostView && !isInPendingPostView && (showReplies || isModQueue) && (
diff --git a/src/views/post/post.tsx b/src/views/post/post.tsx index 7d3ffcab..8ea0cd0d 100644 --- a/src/views/post/post.tsx +++ b/src/views/post/post.tsx @@ -32,7 +32,6 @@ export interface PostProps { onApprove?: () => void; onReject?: () => void; quotedByMap?: Map; - cidToReply?: Map; isInPostPageView?: boolean; }