[Glitch] Further clean up types for the card object

Port 973fef4b697428c7e9f440e9d67fcdc027cff7be to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion 2026-01-09 15:40:27 +01:00 committed by Claire
parent 124d6e37eb
commit 18d4606cce
3 changed files with 10 additions and 9 deletions

View File

@ -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[];
}

View File

@ -104,7 +104,7 @@ const Card: React.FC<CardProps> = ({ 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;
@ -117,7 +117,11 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
{card.get('published_at') && (
<>
{' '}
· <RelativeTimestamp timestamp={card.get('published_at')} />
·{' '}
<RelativeTimestamp
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
timestamp={card.get('published_at')!}
/>
</>
)}
</span>

View File

@ -7,8 +7,6 @@ export type { StatusVisibility } from 'flavours/glitch/api_types/statuses';
// Temporary until we type it correctly
export type Status = Immutable.Map<string, unknown>;
type CardShape = Required<ApiPreviewCardJSON>;
export type Card = RecordOf<CardShape>;
export type Card = RecordOf<ApiPreviewCardJSON>;
export type MediaAttachment = Immutable.Map<string, unknown>;