From 01dacc82705f0c9a6ef20fe53673de3c06c220e5 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Tue, 16 Jul 2024 13:13:04 +0200 Subject: [PATCH] fix(post): include pending replies in "x replies omitted" count --- src/components/post-desktop/post-desktop.tsx | 5 +++-- src/hooks/use-replies.ts | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index ee553d4d..e497971b 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -344,7 +344,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => { const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => { const { t } = useTranslation(); - const { author, cid, content, link, pinned, postCid, replyCount, subplebbitAddress } = post || {}; + const { author, cid, content, link, pinned, postCid, subplebbitAddress } = post || {}; const { isDescription, isRules } = post || {}; // custom properties, not from api const params = useParams(); const location = useLocation(); @@ -357,6 +357,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies const replies = useReplies(post); const visiblelinksCount = useCountLinksInReplies(post, 5); const totalLinksCount = useCountLinksInReplies(post); + const replyCount = replies?.length; const repliesCount = pinned ? replyCount : replyCount - 5; const linksCount = pinned ? totalLinksCount : totalLinksCount - visiblelinksCount; const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies(); @@ -391,7 +392,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies {!isHidden && !content &&
} {!isHidden && content && }
- {!isHidden && !isDescription && !isRules && !isInPendingPostView && (repliesCount > 5 || (pinned && repliesCount > 0)) && !isInPostPageView && ( + {!isHidden && !isDescription && !isRules && !isInPendingPostView && (replyCount > 5 || (pinned && repliesCount > 0)) && !isInPostPageView && ( { // filter against the original comment's CID and all CIDs in flattened replies const filter = useCallback( (accountComment: Comment) => { - const parentCid = accountComment.parentCid || 'n/a'; - const isCidInDocument = !!document.querySelector(`[data-cid="${parentCid}"]`); - return parentCid === (comment?.cid || 'n/a') || replyCids.has(parentCid) || isCidInDocument; + const parentCid = accountComment.parentCid; + return parentCid === (comment?.cid || 'n/a') || replyCids.has(parentCid); }, [comment?.cid, replyCids], );