From 973fef4b697428c7e9f440e9d67fcdc027cff7be Mon Sep 17 00:00:00 2001 From: diondiondion Date: Fri, 9 Jan 2026 15:40:27 +0100 Subject: [PATCH] Further clean up types for the `card` object (#37023) --- app/javascript/mastodon/api_types/statuses.ts | 7 +++---- .../mastodon/features/status/components/card.tsx | 8 ++++++-- app/javascript/mastodon/models/status.ts | 4 +--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/javascript/mastodon/api_types/statuses.ts b/app/javascript/mastodon/api_types/statuses.ts index 1451ea82a0..d61d8ceed0 100644 --- a/app/javascript/mastodon/api_types/statuses.ts +++ b/app/javascript/mastodon/api_types/statuses.ts @@ -41,11 +41,10 @@ export interface ApiPreviewCardJSON { url: string; title: string; description: string; - language: string; - type: string; + language: string | null; + type: 'video' | 'link'; author_name: string; author_url: string; - author_account?: ApiAccountJSON; provider_name: string; provider_url: string; html: string; @@ -55,7 +54,7 @@ export interface ApiPreviewCardJSON { image_description: string; embed_url: string; blurhash: string; - published_at: string; + published_at: string | null; authors: ApiPreviewCardAuthorJSON[]; } diff --git a/app/javascript/mastodon/features/status/components/card.tsx b/app/javascript/mastodon/features/status/components/card.tsx index d060d35c2c..68eea5ea36 100644 --- a/app/javascript/mastodon/features/status/components/card.tsx +++ b/app/javascript/mastodon/features/status/components/card.tsx @@ -118,7 +118,7 @@ const Card: React.FC = ({ card, sensitive }) => { ? decodeIDNA(getHostname(card.get('url'))) : card.get('provider_name'); 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 = (hasImage && card.get('width') > card.get('height')) || interactive; @@ -131,7 +131,11 @@ const Card: React.FC = ({ card, sensitive }) => { {card.get('published_at') && ( <> {' '} - · + ·{' '} + )} diff --git a/app/javascript/mastodon/models/status.ts b/app/javascript/mastodon/models/status.ts index 7f9144280c..b043edb9ca 100644 --- a/app/javascript/mastodon/models/status.ts +++ b/app/javascript/mastodon/models/status.ts @@ -7,8 +7,6 @@ export type { StatusVisibility } from 'mastodon/api_types/statuses'; // Temporary until we type it correctly export type Status = Immutable.Map; -type CardShape = Required; - -export type Card = RecordOf; +export type Card = RecordOf; export type MediaAttachment = Immutable.Map;