fix: sensitive media card display (#39366)

This commit is contained in:
Nishiki 2026-06-11 01:14:53 -07:00 committed by GitHub
parent fd2e3d53eb
commit 40bf2dca1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,7 @@ import { Blurhash } from 'mastodon/components/blurhash';
import { Icon } from 'mastodon/components/icon';
import { MoreFromAuthor } from 'mastodon/components/more_from_author';
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
import { useBlurhash } from 'mastodon/initial_state';
import { displayMedia, useBlurhash } from 'mastodon/initial_state';
import type { Card as CardType } from 'mastodon/models/status';
const IDNA_PREFIX = 'xn--';
@ -63,6 +63,8 @@ const handleIframeUrl = (html: string, url: string, providerName: string) => {
return html;
};
const hideAllMedia = displayMedia === 'hide_all';
interface CardProps {
card: CardType | null;
sensitive?: boolean;
@ -87,7 +89,7 @@ const CardVideo: React.FC<Pick<CardProps, 'card'>> = ({ card }) => (
const Card: React.FC<CardProps> = ({ card, sensitive }) => {
const [previewLoaded, setPreviewLoaded] = useState(false);
const [embedded, setEmbedded] = useState(false);
const [revealed, setRevealed] = useState(!sensitive);
const [revealed, setRevealed] = useState(!sensitive && !hideAllMedia);
const handleEmbedClick = useCallback(() => {
setEmbedded(true);
@ -283,6 +285,7 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
embed = (
<div className='status-card__image'>
{canvas}
{revealed ? undefined : spoilerButton}
{thumbnail}
</div>
);