fix(replies): hide no-reason removed replies

This commit is contained in:
Tommaso Casaburi
2026-06-23 16:20:15 +07:00
parent da92b2fb0a
commit 4737d37967
4 changed files with 16 additions and 7 deletions
+2 -1
View File
@@ -990,7 +990,8 @@ const PostDesktop = ({
const commentMediaInfo = useCommentMediaInfo(link, thumbnailUrl, linkWidth, linkHeight);
const hasThumbnail = getHasThumbnail(commentMediaInfo, link);
// Author-deleted replies are hidden from thread replies; moderator removals still render their placeholder.
// Author-deleted replies and no-reason moderator removals are hidden from thread replies.
// Moderator removals with a reason still render their placeholder and reason.
const filteredReplies = useMemo(() => filterRepliesForDisplay(freshRepliesForRender), [freshRepliesForRender]);
const postsByAuthorInThread = useMemo(() => getThreadPostCountsByAuthor(resolvedPost, filteredReplies), [resolvedPost, filteredReplies]);
const directRepliesByParentCid = useMemo(() => {
+2 -1
View File
@@ -717,7 +717,8 @@ const PostMobile = ({
const [failedMediaUrl, setFailedMediaUrl] = useState<string | undefined>();
const mediaLoadFailureInfo = failedMediaUrl && failedMediaUrl === resolvedPost?.link ? <MediaLoadFailureInfo url={failedMediaUrl} /> : undefined;
// Author-deleted replies are hidden from thread replies; moderator removals still render their placeholder.
// Author-deleted replies and no-reason moderator removals are hidden from thread replies.
// Moderator removals with a reason still render their placeholder and reason.
const filteredReplies = useMemo(() => filterRepliesForDisplay(freshRepliesForRender), [freshRepliesForRender]);
const postsByAuthorInThread = useMemo(() => getThreadPostCountsByAuthor(resolvedPost, filteredReplies), [resolvedPost, filteredReplies]);
const previewDisplayReplies = useMemo(() => getPreviewDisplayReplies(filteredReplies, BOARD_REPLIES_PREVIEW_VISIBLE_COUNT), [filteredReplies]);
+9 -4
View File
@@ -171,10 +171,15 @@ describe('misc utils', () => {
});
it('builds reply previews, omitted counts, and fallback reply totals', () => {
expect(filterRepliesForDisplay([{ cid: 'visible' }, { cid: 'deleted', deleted: true }, { cid: 'removed', deleted: false }])).toEqual([
{ cid: 'visible' },
{ cid: 'removed', deleted: false },
]);
expect(
filterRepliesForDisplay([
{ cid: 'visible' },
{ cid: 'deleted', deleted: true },
{ cid: 'removed', removed: true },
{ cid: 'blank-reason', reason: ' ', removed: true },
{ cid: 'removed-with-reason', reason: 'off-topic', removed: true },
]),
).toEqual([{ cid: 'visible' }, { cid: 'removed-with-reason', reason: 'off-topic', removed: true }]);
expect(
getPreviewDisplayReplies(
+3 -1
View File
@@ -6,6 +6,8 @@ interface CommentLike {
index?: number;
number?: number;
pendingApproval?: boolean;
reason?: string | null;
removed?: boolean;
state?: string;
timestamp?: number;
}
@@ -44,7 +46,7 @@ export function sortRepliesForDisplay<T extends CommentLike>(replies: T[]): T[]
}
export function filterRepliesForDisplay<T extends CommentLike>(replies: T[]): T[] {
return replies.filter((reply) => !reply.deleted);
return replies.filter((reply) => !reply.deleted && (!reply.removed || Boolean(reply.reason?.trim())));
}
/**