diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index b63366a4..714e4ef3 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -22,7 +22,7 @@ import { ChatsStackParamList } from '../../stacks/types'; import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; import { IEmoji } from '../../definitions/IEmoji'; import { IRoomInfoParam } from '../SearchMessagesView'; -import { TMessageModel } from '../../definitions'; +import { TMessageModel, IUrl } from '../../definitions'; import { Services } from '../../lib/services'; interface IMessagesViewProps { @@ -280,8 +280,25 @@ class MessagesView extends React.Component { try { const result = await this.content.fetchFunc(); if (result.success) { + const urlRenderMessages = result.messages?.map((message: any) => { + if (message.urls && message.urls.length > 0) { + message.urls = message.urls?.map((url: any, index: any) => { + if (url.meta) { + return { + _id: index, + title: url.meta.pageTitle, + description: url.meta.ogDescription, + image: url.meta.ogImage, + url: url.url + } as IUrl; + } + return {} as IUrl; + }); + } + return message; + }); this.setState({ - messages: [...messages, ...result.messages], + messages: [...messages, ...urlRenderMessages], total: result.total, loading: false }); diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index c286d547..2e6252be 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -32,6 +32,7 @@ import styles from './styles'; import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types'; import { IEmoji } from '../../definitions/IEmoji'; import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion'; +import { IUrl } from '../../definitions'; import { Services } from '../../lib/services'; const QUERY_SIZE = 50; @@ -155,9 +156,25 @@ class SearchMessagesView extends React.Component { + if (message.urls && message.urls.length > 0) { + message.urls = message.urls?.map((url, index) => { + if (url.meta) { + return { + _id: index, + title: url.meta.pageTitle, + description: url.meta.ogDescription, + image: url.meta.ogImage, + url: url.url + } as IUrl; + } + return {} as IUrl; + }); + } + return message; + }); + return urlRenderMessages; } - return []; }; getMessages = async (searchText: string, debounced?: boolean) => {