fix: sensitive media card display (#39366)
This commit is contained in:
parent
fd2e3d53eb
commit
40bf2dca1e
@ -13,7 +13,7 @@ import { Blurhash } from 'mastodon/components/blurhash';
|
|||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { MoreFromAuthor } from 'mastodon/components/more_from_author';
|
import { MoreFromAuthor } from 'mastodon/components/more_from_author';
|
||||||
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
|
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';
|
import type { Card as CardType } from 'mastodon/models/status';
|
||||||
|
|
||||||
const IDNA_PREFIX = 'xn--';
|
const IDNA_PREFIX = 'xn--';
|
||||||
@ -63,6 +63,8 @@ const handleIframeUrl = (html: string, url: string, providerName: string) => {
|
|||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hideAllMedia = displayMedia === 'hide_all';
|
||||||
|
|
||||||
interface CardProps {
|
interface CardProps {
|
||||||
card: CardType | null;
|
card: CardType | null;
|
||||||
sensitive?: boolean;
|
sensitive?: boolean;
|
||||||
@ -87,7 +89,7 @@ const CardVideo: React.FC<Pick<CardProps, 'card'>> = ({ card }) => (
|
|||||||
const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
||||||
const [previewLoaded, setPreviewLoaded] = useState(false);
|
const [previewLoaded, setPreviewLoaded] = useState(false);
|
||||||
const [embedded, setEmbedded] = useState(false);
|
const [embedded, setEmbedded] = useState(false);
|
||||||
const [revealed, setRevealed] = useState(!sensitive);
|
const [revealed, setRevealed] = useState(!sensitive && !hideAllMedia);
|
||||||
|
|
||||||
const handleEmbedClick = useCallback(() => {
|
const handleEmbedClick = useCallback(() => {
|
||||||
setEmbedded(true);
|
setEmbedded(true);
|
||||||
@ -283,6 +285,7 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
|||||||
embed = (
|
embed = (
|
||||||
<div className='status-card__image'>
|
<div className='status-card__image'>
|
||||||
{canvas}
|
{canvas}
|
||||||
|
{revealed ? undefined : spoilerButton}
|
||||||
{thumbnail}
|
{thumbnail}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user