[Glitch] Fix null access error in card component

Port ee7e756e89 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion
2025-11-26 15:55:40 +01:00
committed by Claire
parent 3b4b57e950
commit 9d47d6790f
2 changed files with 4 additions and 4 deletions

View File

@@ -51,7 +51,7 @@ export interface ApiPreviewCardJSON {
html: string;
width: number;
height: number;
image: string;
image: string | null;
image_description: string;
embed_url: string;
blurhash: string;

View File

@@ -103,9 +103,9 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
: card.get('provider_name');
const interactive = card.get('type') === 'video';
const language = card.get('language') || '';
const hasImage = (card.get('image')?.length ?? 0) > 0;
const largeImage =
(card.get('image').length > 0 && card.get('width') > card.get('height')) ||
interactive;
(hasImage && card.get('width') > card.get('height')) || interactive;
const showAuthor = !!card.getIn(['authors', 0, 'accountId']);
const description = (
@@ -171,7 +171,7 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
const thumbnailDescription = card.get('image_description');
const thumbnail = (
<img
src={card.get('image')}
src={card.get('image') ?? undefined}
alt={thumbnailDescription}
title={thumbnailDescription}
lang={language}