fix: forum stats render according to moderation toggle

This commit is contained in:
Danish Arora 2025-09-10 17:04:22 +05:30
parent 684cb119e8
commit af75b5eef4
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E

View File

@ -303,10 +303,17 @@ export function useForumData(): ForumData {
}, [postsWithVoteStatus, showModerated]);
const filteredComments = useMemo(() => {
return showModerated
? commentsWithVoteStatus
: commentsWithVoteStatus.filter(comment => !comment.moderated);
}, [commentsWithVoteStatus, showModerated]);
if (showModerated) return commentsWithVoteStatus;
// Hide moderated comments AND comments whose parent post is moderated
const moderatedPostIds = new Set(
postsWithVoteStatus.filter(p => p.moderated).map(p => p.id)
);
return commentsWithVoteStatus.filter(
comment => !comment.moderated && !moderatedPostIds.has(comment.postId)
);
}, [commentsWithVoteStatus, postsWithVoteStatus, showModerated]);
// Filtered cells with stats based on filtered posts
const filteredCellsWithStats = useMemo((): CellWithStats[] => {