mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post): include pending replies in "x replies omitted" count
This commit is contained in:
@@ -344,7 +344,7 @@ const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
|
|||||||
|
|
||||||
const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
|
const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
|
||||||
const { t } = useTranslation();
|
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 { isDescription, isRules } = post || {}; // custom properties, not from api
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -357,6 +357,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
|
|||||||
const replies = useReplies(post);
|
const replies = useReplies(post);
|
||||||
const visiblelinksCount = useCountLinksInReplies(post, 5);
|
const visiblelinksCount = useCountLinksInReplies(post, 5);
|
||||||
const totalLinksCount = useCountLinksInReplies(post);
|
const totalLinksCount = useCountLinksInReplies(post);
|
||||||
|
const replyCount = replies?.length;
|
||||||
const repliesCount = pinned ? replyCount : replyCount - 5;
|
const repliesCount = pinned ? replyCount : replyCount - 5;
|
||||||
const linksCount = pinned ? totalLinksCount : totalLinksCount - visiblelinksCount;
|
const linksCount = pinned ? totalLinksCount : totalLinksCount - visiblelinksCount;
|
||||||
const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies();
|
const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies();
|
||||||
@@ -391,7 +392,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
|
|||||||
{!isHidden && !content && <div className={styles.spacer} />}
|
{!isHidden && !content && <div className={styles.spacer} />}
|
||||||
{!isHidden && content && <PostMessage post={post} />}
|
{!isHidden && content && <PostMessage post={post} />}
|
||||||
</div>
|
</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={styles.summary}>
|
||||||
<span
|
<span
|
||||||
className={`${showOmittedReplies[cid] ? styles.hideOmittedReplies : styles.showOmittedReplies} ${styles.omittedRepliesButtonWrapper}`}
|
className={`${showOmittedReplies[cid] ? styles.hideOmittedReplies : styles.showOmittedReplies} ${styles.omittedRepliesButtonWrapper}`}
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ const useReplies = (comment: Comment) => {
|
|||||||
// filter against the original comment's CID and all CIDs in flattened replies
|
// filter against the original comment's CID and all CIDs in flattened replies
|
||||||
const filter = useCallback(
|
const filter = useCallback(
|
||||||
(accountComment: Comment) => {
|
(accountComment: Comment) => {
|
||||||
const parentCid = accountComment.parentCid || 'n/a';
|
const parentCid = accountComment.parentCid;
|
||||||
const isCidInDocument = !!document.querySelector(`[data-cid="${parentCid}"]`);
|
return parentCid === (comment?.cid || 'n/a') || replyCids.has(parentCid);
|
||||||
return parentCid === (comment?.cid || 'n/a') || replyCids.has(parentCid) || isCidInDocument;
|
|
||||||
},
|
},
|
||||||
[comment?.cid, replyCids],
|
[comment?.cid, replyCids],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user