From 56b22e7ea9934bf0dc71853101aeb41b3622df0d Mon Sep 17 00:00:00 2001 From: Tommaso Casaburi Date: Tue, 28 Jul 2026 14:28:37 +0700 Subject: [PATCH] fix(transfer): hide transferred label on trash board posts Posts moved to /trash/ should not show the transferred tag since the move is the intended outcome. --- .../__tests__/post-transferred-tag.test.tsx | 17 +++++++++++++++++ src/components/post-transferred-tag.tsx | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/components/__tests__/post-transferred-tag.test.tsx b/src/components/__tests__/post-transferred-tag.test.tsx index 5d21691a..a238fdf3 100644 --- a/src/components/__tests__/post-transferred-tag.test.tsx +++ b/src/components/__tests__/post-transferred-tag.test.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { createElement } from 'react'; import { createRoot, type Root } from 'react-dom/client'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { TRASH_BOARD_ADDRESS } from '../../lib/special-boards'; import PostTransferredTag from '../post-transferred-tag'; (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true; @@ -36,6 +37,22 @@ describe('PostTransferredTag', () => { expect(container.textContent).toBe('[Transferred] '); }); + it('does not render the transferred label for posts moved to trash', async () => { + await act(async () => { + root.render( + createElement(PostTransferredTag, { + comment: { + commentModeration: { flairs: [{ text: '5chan:transferred' }] }, + communityAddress: TRASH_BOARD_ADDRESS, + title: 'Original title', + }, + }), + ); + }); + + expect(container.textContent).toBe(''); + }); + it('ignores user-authored transferred-looking flairs', async () => { await act(async () => { root.render(createElement(PostTransferredTag, { comment: { flairs: [{ text: '5chan:transferred' }] } })); diff --git a/src/components/post-transferred-tag.tsx b/src/components/post-transferred-tag.tsx index 5b405535..d33537de 100644 --- a/src/components/post-transferred-tag.tsx +++ b/src/components/post-transferred-tag.tsx @@ -1,5 +1,7 @@ import { useTranslation } from 'react-i18next'; import { hasTransferredCommentMarker } from '../lib/comment-transfer'; +import { getSpecialBoardByAddress, TRASH_BOARD_CODE } from '../lib/special-boards'; +import { getCommentCommunityAddress } from '../lib/utils/comment-utils'; import styles from './post-transferred-tag.module.css'; interface PostTransferredTagProps { @@ -10,6 +12,9 @@ const PostTransferredTag = ({ comment }: PostTransferredTagProps) => { const { t } = useTranslation(); if (!hasTransferredCommentMarker(comment)) return null; + if (getSpecialBoardByAddress(getCommentCommunityAddress(comment))?.directoryCode === TRASH_BOARD_CODE) { + return null; + } return (