mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(replies): hide author-deleted replies from thread views
This commit is contained in:
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { copyToClipboard } from '../clipboard-utils';
|
||||
import { hashStringToColor, getTextColorForBackground, removeMarkdown } from '../post-utils';
|
||||
import { preloadThemeAssets } from '../preload-utils';
|
||||
import { computeOmittedCount, getPreviewDisplayReplies, getTotalReplyCount } from '../replies-preview-utils';
|
||||
import { computeOmittedCount, filterRepliesForDisplay, getPreviewDisplayReplies, getTotalReplyCount } from '../replies-preview-utils';
|
||||
import { getQuotedCidsFromContent, mergeQuotedCids } from '../reply-quote-utils';
|
||||
import { formatUserIDForDisplay, truncateWithEllipsisInMiddle } from '../string-utils';
|
||||
import { getFormattedDate, getFormattedTimeAgo, isChristmas } from '../time-utils';
|
||||
@@ -120,6 +120,11 @@ 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(
|
||||
getPreviewDisplayReplies(
|
||||
[
|
||||
|
||||
@@ -2,12 +2,17 @@ import { BOARD_REPLIES_PREVIEW_VISIBLE_COUNT } from '../constants';
|
||||
|
||||
interface CommentLike {
|
||||
cid?: string | null;
|
||||
deleted?: boolean;
|
||||
index?: number;
|
||||
pendingApproval?: boolean;
|
||||
state?: string;
|
||||
timestamp?: number;
|
||||
}
|
||||
|
||||
export function filterRepliesForDisplay<T extends CommentLike>(replies: T[]): T[] {
|
||||
return replies.filter((reply) => !reply.deleted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest N replies in chronological display order (oldest first).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user