Further clean up types for the card object (#37023)
This commit is contained in:
parent
628fc9b95b
commit
973fef4b69
@ -41,11 +41,10 @@ export interface ApiPreviewCardJSON {
|
|||||||
url: string;
|
url: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
language: string;
|
language: string | null;
|
||||||
type: string;
|
type: 'video' | 'link';
|
||||||
author_name: string;
|
author_name: string;
|
||||||
author_url: string;
|
author_url: string;
|
||||||
author_account?: ApiAccountJSON;
|
|
||||||
provider_name: string;
|
provider_name: string;
|
||||||
provider_url: string;
|
provider_url: string;
|
||||||
html: string;
|
html: string;
|
||||||
@ -55,7 +54,7 @@ export interface ApiPreviewCardJSON {
|
|||||||
image_description: string;
|
image_description: string;
|
||||||
embed_url: string;
|
embed_url: string;
|
||||||
blurhash: string;
|
blurhash: string;
|
||||||
published_at: string;
|
published_at: string | null;
|
||||||
authors: ApiPreviewCardAuthorJSON[];
|
authors: ApiPreviewCardAuthorJSON[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
|||||||
? decodeIDNA(getHostname(card.get('url')))
|
? decodeIDNA(getHostname(card.get('url')))
|
||||||
: 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 hasImage = (card.get('image')?.length ?? 0) > 0;
|
||||||
const largeImage =
|
const largeImage =
|
||||||
(hasImage && card.get('width') > card.get('height')) || interactive;
|
(hasImage && card.get('width') > card.get('height')) || interactive;
|
||||||
@ -131,7 +131,11 @@ const Card: React.FC<CardProps> = ({ card, sensitive }) => {
|
|||||||
{card.get('published_at') && (
|
{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>
|
</span>
|
||||||
|
|||||||
@ -7,8 +7,6 @@ export type { StatusVisibility } from 'mastodon/api_types/statuses';
|
|||||||
// Temporary until we type it correctly
|
// Temporary until we type it correctly
|
||||||
export type Status = Immutable.Map<string, unknown>;
|
export type Status = Immutable.Map<string, unknown>;
|
||||||
|
|
||||||
type CardShape = Required<ApiPreviewCardJSON>;
|
export type Card = RecordOf<ApiPreviewCardJSON>;
|
||||||
|
|
||||||
export type Card = RecordOf<CardShape>;
|
|
||||||
|
|
||||||
export type MediaAttachment = Immutable.Map<string, unknown>;
|
export type MediaAttachment = Immutable.Map<string, unknown>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user