mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(replies): hide no-reason removed replies
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user