mirror of
https://github.com/mastodon/mastodon.git
synced 2025-11-27 18:10:58 +00:00
Fix null access error in card component (#37022)
This commit is contained in:
parent
f87f30c1ac
commit
ee7e756e89
|
|
@ -51,7 +51,7 @@ export interface ApiPreviewCardJSON {
|
||||||
html: string;
|
html: string;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
image: string;
|
image: string | null;
|
||||||
image_description: string;
|
image_description: string;
|
||||||
embed_url: string;
|
embed_url: string;
|
||||||
blurhash: string;
|
blurhash: string;
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,9 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
||||||
: card.get('provider_name');
|
: card.get('provider_name');
|
||||||
const interactive = card.get('type') === 'video';
|
const interactive = card.get('type') === 'video';
|
||||||
const language = card.get('language') || '';
|
const language = card.get('language') || '';
|
||||||
|
const hasImage = (card.get('image')?.length ?? 0) > 0;
|
||||||
const largeImage =
|
const largeImage =
|
||||||
(card.get('image').length > 0 && card.get('width') > card.get('height')) ||
|
(hasImage && card.get('width') > card.get('height')) || interactive;
|
||||||
interactive;
|
|
||||||
const showAuthor = !!card.getIn(['authors', 0, 'accountId']);
|
const showAuthor = !!card.getIn(['authors', 0, 'accountId']);
|
||||||
|
|
||||||
const description = (
|
const description = (
|
||||||
|
|
@ -185,7 +185,7 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
||||||
const thumbnailDescription = card.get('image_description');
|
const thumbnailDescription = card.get('image_description');
|
||||||
const thumbnail = (
|
const thumbnail = (
|
||||||
<img
|
<img
|
||||||
src={card.get('image')}
|
src={card.get('image') ?? undefined}
|
||||||
alt={thumbnailDescription}
|
alt={thumbnailDescription}
|
||||||
title={thumbnailDescription}
|
title={thumbnailDescription}
|
||||||
lang={language}
|
lang={language}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user