fix(reply): no need to render deleted replies that have no children

This commit is contained in:
Tom (plebeius.eth)
2025-06-03 22:18:32 +02:00
parent b49216b555
commit f233da9806
2 changed files with 16 additions and 10 deletions
+8 -5
View File
@@ -450,11 +450,14 @@ const PostDesktop = ({ post, roles, showAllReplies, showReplies = true }: PostPr
!isInPendingPostView && !isInPendingPostView &&
replies && replies &&
showReplies && showReplies &&
(showAllReplies || showOmittedReplies[cid] ? replies : replies.slice(-5)).map((reply, index) => ( (showAllReplies || showOmittedReplies[cid] ? replies : replies.slice(-5))
<div key={index} className={styles.replyContainer}> // Don't render deleted replies that have no children (replyCount = 0)
<Reply reply={reply} roles={roles} postReplyCount={replyCount} /> .filter((reply) => !(reply.deleted && (reply.replyCount === 0 || !reply.replyCount)))
</div> .map((reply, index) => (
))} <div key={index} className={styles.replyContainer}>
<Reply reply={reply} roles={roles} postReplyCount={replyCount} />
</div>
))}
{isDescription && subplebbit?.rules && subplebbit?.rules.length > 0 && ( {isDescription && subplebbit?.rules && subplebbit?.rules.length > 0 && (
<div className={styles.replyContainer}> <div className={styles.replyContainer}>
<Reply reply={subplebbitRulesReply} /> <Reply reply={subplebbitRulesReply} />
+8 -5
View File
@@ -359,11 +359,14 @@ const PostMobile = ({ post, roles, showAllReplies, showReplies = true }: PostPro
!isInPendingPostView && !isInPendingPostView &&
replies && replies &&
showReplies && showReplies &&
(showAllReplies ? replies : replies.slice(-5)).map((reply, index) => ( (showAllReplies ? replies : replies.slice(-5))
<div key={index} className={styles.replyContainer}> // Don't render deleted replies that have no children (replyCount = 0)
<Reply postReplyCount={replyCount} reply={reply} roles={roles} /> .filter((reply) => !(reply.deleted && (reply.replyCount === 0 || !reply.replyCount)))
</div> .map((reply, index) => (
))} <div key={index} className={styles.replyContainer}>
<Reply postReplyCount={replyCount} reply={reply} roles={roles} />
</div>
))}
{showRules && ( {showRules && (
<div className={styles.replyContainer}> <div className={styles.replyContainer}>
<Reply reply={subplebbitRulesReply} /> <Reply reply={subplebbitRulesReply} />