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 { IEditedBy, IUserChannel, IUserMention, IUserMessage } from './IMessage';
|
||||||
import { IReaction } from './IReaction';
|
import { IReaction } from './IReaction';
|
||||||
import { SubscriptionType } from './ISubscription';
|
import { SubscriptionType } from './ISubscription';
|
||||||
|
import { IUrl } from './IUrl';
|
||||||
export interface IUrl {
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
image: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IFileThread {
|
interface IFileThread {
|
||||||
_id: string;
|
_id: string;
|
||||||
|
|
|
@ -1,6 +1,49 @@
|
||||||
export interface IUrl {
|
export interface IUrl {
|
||||||
|
_id: number;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
image: string;
|
image: string;
|
||||||
url: 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 './IServerHistory';
|
||||||
export * from './IRocketChat';
|
export * from './IRocketChat';
|
||||||
export * from './ICertificate';
|
export * from './ICertificate';
|
||||||
|
export * from './IUrl';
|
||||||
|
|
||||||
export interface IBaseScreen<T extends Record<string, object | undefined>, S extends string> {
|
export interface IBaseScreen<T extends Record<string, object | undefined>, S extends string> {
|
||||||
navigation: StackNavigationProp<T, S>;
|
navigation: StackNavigationProp<T, S>;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
export default urls =>
|
import { IUrl, IUrlFromServer } from '../../../definitions';
|
||||||
|
|
||||||
|
export default (urls: IUrlFromServer[]): IUrl[] =>
|
||||||
urls
|
urls
|
||||||
.filter(url => url.meta && !url.ignoreParse)
|
.filter((url: IUrlFromServer) => url.meta && !url.ignoreParse)
|
||||||
.map((url, index) => {
|
.map((url: IUrlFromServer, index) => {
|
||||||
const tmp = {};
|
const tmp: IUrl = {} as any;
|
||||||
const { meta } = url;
|
const { meta } = url;
|
||||||
tmp._id = index;
|
tmp._id = index;
|
||||||
tmp.title = meta.ogTitle || meta.twitterTitle || meta.title || meta.pageTitle || meta.oembedTitle;
|
tmp.title = meta.ogTitle || meta.twitterTitle || meta.title || meta.pageTitle || meta.oembedTitle;
|
Loading…
Reference in New Issue