fix(post): include pending replies in "x replies omitted" count

This commit is contained in:
Tom (plebeius.eth)
2024-07-16 13:13:04 +02:00
parent 75ed99c578
commit 01dacc8270
2 changed files with 5 additions and 5 deletions
+3 -2
View File
@@ -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 && <div className={styles.spacer} />}
{!isHidden && content && <PostMessage post={post} />}
</div>
{!isHidden && !isDescription && !isRules && !isInPendingPostView && (repliesCount > 5 || (pinned && repliesCount > 0)) && !isInPostPageView && (
{!isHidden && !isDescription && !isRules && !isInPendingPostView && (replyCount > 5 || (pinned && repliesCount > 0)) && !isInPostPageView && (
<span className={styles.summary}>
<span
className={`${showOmittedReplies[cid] ? styles.hideOmittedReplies : styles.showOmittedReplies} ${styles.omittedRepliesButtonWrapper}`}
+2 -3
View File
@@ -12,9 +12,8 @@ const useReplies = (comment: Comment) => {
// 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],
);