url preview is visible when we see messages in pinned, mentions and starred messages
This commit is contained in:
parent
577fb468eb
commit
99ab3f3ef7
|
@ -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
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue