url preview is visible when we see messages in pinned, mentions and starred messages

This commit is contained in:
samay-kothari 2022-04-17 23:00:27 +05:30
parent 577fb468eb
commit 99ab3f3ef7
1 changed files with 19 additions and 2 deletions

View File

@ -23,7 +23,7 @@ import { ChatsStackParamList } from '../../stacks/types';
import { ISubscription, SubscriptionType } from '../../definitions/ISubscription'; import { ISubscription, SubscriptionType } from '../../definitions/ISubscription';
import { IEmoji } from '../../definitions/IEmoji'; import { IEmoji } from '../../definitions/IEmoji';
import { IRoomInfoParam } from '../SearchMessagesView'; import { IRoomInfoParam } from '../SearchMessagesView';
import { TMessageModel } from '../../definitions'; import { TMessageModel, IUrl } from '../../definitions';
interface IMessagesViewProps { interface IMessagesViewProps {
user: { user: {
@ -280,8 +280,25 @@ class MessagesView extends React.Component<IMessagesViewProps, any> {
try { try {
const result = await this.content.fetchFunc(); const result = await this.content.fetchFunc();
if (result.success) { 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({ this.setState({
messages: [...messages, ...result.messages], messages: [...messages, ...urlRenderMessages],
total: result.total, total: result.total,
loading: false loading: false
}); });