Chore: Migrate helpers/parseUrls to Typescript (#3735)
This commit is contained in:
parent
78da41d4f7
commit
941a21dac6
|
@ -5,13 +5,7 @@ import { IAttachment } from './IAttachment';
|
|||
import { IEditedBy, IUserChannel, IUserMention, IUserMessage } from './IMessage';
|
||||
import { IReaction } from './IReaction';
|
||||
import { SubscriptionType } from './ISubscription';
|
||||
|
||||
export interface IUrl {
|
||||
title: string;
|
||||
description: string;
|
||||
image: string;
|
||||
url: string;
|
||||
}
|
||||
import { IUrl } from './IUrl';
|
||||
|
||||
interface IFileThread {
|
||||
_id: string;
|
||||
|
|
|
@ -1,6 +1,49 @@
|
|||
export interface IUrl {
|
||||
_id: number;
|
||||
title: string;
|
||||
description: string;
|
||||
image: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface IUrlFromServer {
|
||||
url: string;
|
||||
meta: {
|
||||
pageTitle: string;
|
||||
description: string;
|
||||
fbAppId: string;
|
||||
twitterImageSrc: string;
|
||||
twitterSite: string;
|
||||
twitterCard: string;
|
||||
twitterTitle: string;
|
||||
twitterDescription: string;
|
||||
ogImage: string;
|
||||
ogImageAlt: string;
|
||||
ogImageWidth: string;
|
||||
ogImageHeight: string;
|
||||
ogSiteName: string;
|
||||
ogType: string;
|
||||
ogTitle: string;
|
||||
ogUrl: string;
|
||||
ogDescription: string;
|
||||
title: string;
|
||||
oembedTitle: string;
|
||||
oembedAuthorName: string;
|
||||
twitterImage: string;
|
||||
oembedThumbnailUrl: string;
|
||||
};
|
||||
headers: {
|
||||
contentType: string;
|
||||
};
|
||||
parsedUrl: {
|
||||
host: string;
|
||||
hash: any;
|
||||
pathname: string;
|
||||
protocol: string;
|
||||
port: any;
|
||||
query: any;
|
||||
search: any;
|
||||
hostname: string;
|
||||
};
|
||||
ignoreParse: boolean;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ export * from './ILoggedUser';
|
|||
export * from './IServerHistory';
|
||||
export * from './IRocketChat';
|
||||
export * from './ICertificate';
|
||||
export * from './IUrl';
|
||||
|
||||
export interface IBaseScreen<T extends Record<string, object | undefined>, S extends string> {
|
||||
navigation: StackNavigationProp<T, S>;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
export default urls =>
|
||||
import { IUrl, IUrlFromServer } from '../../../definitions';
|
||||
|
||||
export default (urls: IUrlFromServer[]): IUrl[] =>
|
||||
urls
|
||||
.filter(url => url.meta && !url.ignoreParse)
|
||||
.map((url, index) => {
|
||||
const tmp = {};
|
||||
.filter((url: IUrlFromServer) => url.meta && !url.ignoreParse)
|
||||
.map((url: IUrlFromServer, index) => {
|
||||
const tmp: IUrl = {} as any;
|
||||
const { meta } = url;
|
||||
tmp._id = index;
|
||||
tmp.title = meta.ogTitle || meta.twitterTitle || meta.title || meta.pageTitle || meta.oembedTitle;
|
Loading…
Reference in New Issue