From 99ab3f3ef7760d35878e9dec574b4b8528761f5b Mon Sep 17 00:00:00 2001 From: samay-kothari <2001samay@gmail.com> Date: Sun, 17 Apr 2022 23:00:27 +0530 Subject: [PATCH] url preview is visible when we see messages in pinned, mentions and starred messages --- app/views/MessagesView/index.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index f91742d77..c298d3705 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -23,7 +23,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'; interface IMessagesViewProps { user: { @@ -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 });