mirror of
https://github.com/mastodon/mastodon.git
synced 2026-01-11 19:56:37 +00:00
Further clean up types for the card object (#37023)
This commit is contained in:
parent
628fc9b95b
commit
973fef4b69
3 changed files with 10 additions and 9 deletions
|
|
@ -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[];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,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;
|
||||
|
|
@ -131,7 +131,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>
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ export type { StatusVisibility } from 'mastodon/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>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue