2019-05-10 17:09:07 +00:00
|
|
|
import React from 'react';
|
2021-09-13 20:41:05 +00:00
|
|
|
import { FlatList, Text, View } from 'react-native';
|
2019-05-10 17:09:07 +00:00
|
|
|
import { connect } from 'react-redux';
|
2021-02-26 16:01:45 +00:00
|
|
|
import { dequal } from 'dequal';
|
2021-11-16 16:10:49 +00:00
|
|
|
import { StackNavigationProp } from '@react-navigation/stack';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { CompositeNavigationProp, RouteProp } from '@react-navigation/core';
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-12-03 19:27:57 +00:00
|
|
|
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
|
2020-05-08 17:07:58 +00:00
|
|
|
import Message from '../../containers/message';
|
2019-12-04 16:39:53 +00:00
|
|
|
import ActivityIndicator from '../../containers/ActivityIndicator';
|
2019-05-10 17:09:07 +00:00
|
|
|
import I18n from '../../i18n';
|
|
|
|
import RocketChat from '../../lib/rocketchat';
|
|
|
|
import StatusBar from '../../containers/StatusBar';
|
|
|
|
import getFileUrlFromMessage from '../../lib/methods/helpers/getFileUrlFromMessage';
|
2019-12-04 16:39:53 +00:00
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import { withTheme } from '../../theme';
|
2020-02-11 14:09:14 +00:00
|
|
|
import { getUserSelector } from '../../selectors/login';
|
2020-06-15 19:35:45 +00:00
|
|
|
import { withActionSheet } from '../../containers/ActionSheet';
|
2020-06-15 14:00:46 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
2021-05-26 17:24:54 +00:00
|
|
|
import getThreadName from '../../lib/methods/getThreadName';
|
2021-09-13 20:41:05 +00:00
|
|
|
import styles from './styles';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { ChatsStackParamList } from '../../stacks/types';
|
2022-01-11 13:51:48 +00:00
|
|
|
import { ISubscription, SubscriptionType } from '../../definitions/ISubscription';
|
2022-02-17 15:27:01 +00:00
|
|
|
import { IEmoji } from '../../definitions/IEmoji';
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
interface IMessagesViewProps {
|
|
|
|
user: {
|
|
|
|
id: string;
|
2022-01-17 16:10:39 +00:00
|
|
|
username: string;
|
|
|
|
token: string;
|
2021-11-16 16:10:49 +00:00
|
|
|
};
|
|
|
|
baseUrl: string;
|
2021-12-03 19:27:57 +00:00
|
|
|
navigation: CompositeNavigationProp<
|
|
|
|
StackNavigationProp<ChatsStackParamList, 'MessagesView'>,
|
|
|
|
StackNavigationProp<MasterDetailInsideStackParamList>
|
|
|
|
>;
|
|
|
|
route: RouteProp<ChatsStackParamList, 'MessagesView'>;
|
2022-02-17 15:27:01 +00:00
|
|
|
customEmojis: { [key: string]: IEmoji };
|
2021-11-16 16:10:49 +00:00
|
|
|
theme: string;
|
|
|
|
showActionSheet: Function;
|
|
|
|
useRealName: boolean;
|
|
|
|
isMasterDetail: boolean;
|
|
|
|
}
|
|
|
|
|
2021-12-03 19:27:57 +00:00
|
|
|
interface IRoomInfoParam {
|
2022-01-11 13:51:48 +00:00
|
|
|
room: ISubscription;
|
2021-12-03 19:27:57 +00:00
|
|
|
member: any;
|
|
|
|
rid: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
t: SubscriptionType;
|
2021-12-03 19:27:57 +00:00
|
|
|
joined: boolean;
|
|
|
|
}
|
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
interface IMessagesViewState {
|
|
|
|
loading: boolean;
|
|
|
|
messages: [];
|
|
|
|
fileLoading: boolean;
|
|
|
|
total: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IMessageItem {
|
|
|
|
u?: string;
|
|
|
|
user?: string;
|
|
|
|
editedAt?: Date;
|
|
|
|
attachments?: any;
|
|
|
|
_id: string;
|
|
|
|
tmid?: string;
|
|
|
|
ts?: Date;
|
|
|
|
uploadedAt?: Date;
|
|
|
|
name?: string;
|
|
|
|
description?: string;
|
|
|
|
msg?: string;
|
2022-02-15 18:50:55 +00:00
|
|
|
starred: boolean;
|
2021-11-16 16:10:49 +00:00
|
|
|
pinned: boolean;
|
2022-02-21 18:19:40 +00:00
|
|
|
type: string;
|
|
|
|
url: string;
|
2021-11-16 16:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IParams {
|
2021-12-03 19:27:57 +00:00
|
|
|
rid: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
t: SubscriptionType;
|
2021-11-16 16:10:49 +00:00
|
|
|
tmid?: string;
|
2022-03-02 14:18:01 +00:00
|
|
|
message?: object;
|
2021-11-16 16:10:49 +00:00
|
|
|
name?: string;
|
2021-12-03 19:27:57 +00:00
|
|
|
fname?: string;
|
|
|
|
prid?: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
room: ISubscription;
|
2021-12-03 19:27:57 +00:00
|
|
|
jumpToMessageId?: string;
|
|
|
|
jumpToThreadId?: string;
|
|
|
|
roomUserId?: string;
|
2021-11-16 16:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class MessagesView extends React.Component<IMessagesViewProps, any> {
|
2021-12-03 19:27:57 +00:00
|
|
|
private rid: string;
|
2022-01-11 13:51:48 +00:00
|
|
|
private t: SubscriptionType;
|
2021-11-16 16:10:49 +00:00
|
|
|
private content: any;
|
|
|
|
private room: any;
|
|
|
|
|
|
|
|
constructor(props: IMessagesViewProps) {
|
2019-05-28 13:03:08 +00:00
|
|
|
super(props);
|
2019-05-10 17:09:07 +00:00
|
|
|
this.state = {
|
|
|
|
loading: false,
|
2019-05-20 20:43:50 +00:00
|
|
|
messages: [],
|
2019-08-26 16:56:39 +00:00
|
|
|
fileLoading: true
|
2019-05-10 17:09:07 +00:00
|
|
|
};
|
2020-07-24 19:58:14 +00:00
|
|
|
this.setHeader();
|
2020-06-15 14:00:46 +00:00
|
|
|
this.rid = props.route.params?.rid;
|
|
|
|
this.t = props.route.params?.t;
|
|
|
|
this.content = this.defineMessagesViewContent(props.route.params?.name);
|
2019-05-10 17:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.load();
|
|
|
|
}
|
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
shouldComponentUpdate(nextProps: IMessagesViewProps, nextState: any) {
|
2021-09-13 20:41:05 +00:00
|
|
|
const { loading, messages, fileLoading } = this.state;
|
2019-12-04 16:39:53 +00:00
|
|
|
const { theme } = this.props;
|
|
|
|
if (nextProps.theme !== theme) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-10 17:09:07 +00:00
|
|
|
if (nextState.loading !== loading) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-02-26 16:01:45 +00:00
|
|
|
if (!dequal(nextState.messages, messages)) {
|
2019-05-10 17:09:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-08-26 16:56:39 +00:00
|
|
|
if (fileLoading !== nextState.fileLoading) {
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-10 17:09:07 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-07-24 19:58:14 +00:00
|
|
|
|
|
|
|
setHeader = () => {
|
|
|
|
const { route, navigation } = this.props;
|
|
|
|
navigation.setOptions({
|
|
|
|
title: I18n.t(route.params?.name)
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-12-03 19:27:57 +00:00
|
|
|
navToRoomInfo = (navParam: IRoomInfoParam) => {
|
2020-02-17 16:06:46 +00:00
|
|
|
const { navigation, user } = this.props;
|
|
|
|
if (navParam.rid === user.id) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
navigation.navigate('RoomInfoView', navParam);
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-02-17 16:06:46 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
jumpToMessage = async ({ item }: { item: IMessageItem }) => {
|
2021-05-26 17:24:54 +00:00
|
|
|
const { navigation, isMasterDetail } = this.props;
|
2021-11-16 16:10:49 +00:00
|
|
|
let params: IParams = {
|
2021-05-26 17:24:54 +00:00
|
|
|
rid: this.rid,
|
|
|
|
jumpToMessageId: item._id,
|
|
|
|
t: this.t,
|
|
|
|
room: this.room
|
|
|
|
};
|
|
|
|
if (item.tmid) {
|
|
|
|
if (isMasterDetail) {
|
|
|
|
navigation.navigate('DrawerNavigator');
|
|
|
|
} else {
|
|
|
|
navigation.pop(2);
|
|
|
|
}
|
|
|
|
params = {
|
|
|
|
...params,
|
|
|
|
tmid: item.tmid,
|
|
|
|
name: await getThreadName(this.rid, item.tmid, item._id),
|
2022-01-11 13:51:48 +00:00
|
|
|
t: SubscriptionType.THREAD
|
2021-05-26 17:24:54 +00:00
|
|
|
};
|
|
|
|
navigation.push('RoomView', params);
|
|
|
|
} else {
|
|
|
|
navigation.navigate('RoomView', params);
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2021-05-26 17:24:54 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
defineMessagesViewContent = (name: string) => {
|
2021-09-13 20:41:05 +00:00
|
|
|
const { user, baseUrl, theme, useRealName } = this.props;
|
2021-11-16 16:10:49 +00:00
|
|
|
const renderItemCommonProps = (item: IMessageItem) => ({
|
2020-05-08 17:07:58 +00:00
|
|
|
item,
|
2019-05-10 17:09:07 +00:00
|
|
|
baseUrl,
|
|
|
|
user,
|
|
|
|
author: item.u || item.user,
|
|
|
|
timeFormat: 'MMM Do YYYY, h:mm:ss a',
|
2019-05-20 20:43:50 +00:00
|
|
|
isEdited: !!item.editedAt,
|
|
|
|
isHeader: true,
|
2021-05-26 17:24:54 +00:00
|
|
|
isThreadRoom: true,
|
2019-05-20 20:43:50 +00:00
|
|
|
attachments: item.attachments || [],
|
2020-08-26 14:06:14 +00:00
|
|
|
useRealName,
|
2019-12-18 21:13:11 +00:00
|
|
|
showAttachment: this.showAttachment,
|
2020-02-17 16:06:46 +00:00
|
|
|
getCustomEmoji: this.getCustomEmoji,
|
2021-05-26 17:24:54 +00:00
|
|
|
navToRoomInfo: this.navToRoomInfo,
|
|
|
|
onPress: () => this.jumpToMessage({ item })
|
2019-05-10 17:09:07 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
return {
|
2019-05-10 17:09:07 +00:00
|
|
|
// Files Messages Screen
|
|
|
|
Files: {
|
|
|
|
name: I18n.t('Files'),
|
2021-09-13 20:41:05 +00:00
|
|
|
fetchFunc: async () => {
|
2020-07-17 18:59:18 +00:00
|
|
|
const { messages } = this.state;
|
2019-05-10 17:09:07 +00:00
|
|
|
const result = await RocketChat.getFiles(this.rid, this.t, messages.length);
|
2022-03-10 01:31:50 +00:00
|
|
|
if (result.success) {
|
|
|
|
return { ...result, messages: result.files };
|
|
|
|
}
|
2019-05-10 17:09:07 +00:00
|
|
|
},
|
|
|
|
noDataMsg: I18n.t('No_files'),
|
|
|
|
testID: 'room-files-view',
|
2022-03-02 14:18:01 +00:00
|
|
|
renderItem: (item: any) => (
|
2020-05-08 17:07:58 +00:00
|
|
|
<Message
|
|
|
|
{...renderItemCommonProps(item)}
|
|
|
|
item={{
|
|
|
|
...item,
|
|
|
|
u: item.user,
|
2020-08-25 20:09:52 +00:00
|
|
|
ts: item.ts || item.uploadedAt,
|
2021-09-13 20:41:05 +00:00
|
|
|
attachments: [
|
|
|
|
{
|
|
|
|
title: item.name,
|
|
|
|
description: item.description,
|
|
|
|
...getFileUrlFromMessage(item)
|
|
|
|
}
|
|
|
|
]
|
2020-05-08 17:07:58 +00:00
|
|
|
}}
|
|
|
|
theme={theme}
|
|
|
|
/>
|
|
|
|
)
|
2019-05-10 17:09:07 +00:00
|
|
|
},
|
|
|
|
// Mentions Messages Screen
|
|
|
|
Mentions: {
|
|
|
|
name: I18n.t('Mentions'),
|
2020-07-17 18:59:18 +00:00
|
|
|
fetchFunc: () => {
|
|
|
|
const { messages } = this.state;
|
2021-09-13 20:41:05 +00:00
|
|
|
return RocketChat.getMessages(this.rid, this.t, { 'mentions._id': { $in: [user.id] } }, messages.length);
|
2020-07-17 18:59:18 +00:00
|
|
|
},
|
2019-05-10 17:09:07 +00:00
|
|
|
noDataMsg: I18n.t('No_mentioned_messages'),
|
|
|
|
testID: 'mentioned-messages-view',
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: unify IMessage
|
2021-11-16 16:10:49 +00:00
|
|
|
renderItem: (item: IMessageItem) => <Message {...renderItemCommonProps(item)} msg={item.msg} theme={theme} />
|
2019-05-10 17:09:07 +00:00
|
|
|
},
|
|
|
|
// Starred Messages Screen
|
|
|
|
Starred: {
|
|
|
|
name: I18n.t('Starred'),
|
2020-07-17 18:59:18 +00:00
|
|
|
fetchFunc: () => {
|
|
|
|
const { messages } = this.state;
|
2021-09-13 20:41:05 +00:00
|
|
|
return RocketChat.getMessages(this.rid, this.t, { 'starred._id': { $in: [user.id] } }, messages.length);
|
2020-07-17 18:59:18 +00:00
|
|
|
},
|
2019-05-10 17:09:07 +00:00
|
|
|
noDataMsg: I18n.t('No_starred_messages'),
|
|
|
|
testID: 'starred-messages-view',
|
2021-11-16 16:10:49 +00:00
|
|
|
renderItem: (item: IMessageItem) => (
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: unify IMessage
|
2021-09-13 20:41:05 +00:00
|
|
|
<Message {...renderItemCommonProps(item)} msg={item.msg} onLongPress={() => this.onLongPress(item)} theme={theme} />
|
2019-05-10 17:09:07 +00:00
|
|
|
),
|
2021-11-16 16:10:49 +00:00
|
|
|
action: (message: IMessageItem) => ({
|
2021-09-13 20:41:05 +00:00
|
|
|
title: I18n.t('Unstar'),
|
|
|
|
icon: message.starred ? 'star-filled' : 'star',
|
|
|
|
onPress: this.handleActionPress
|
|
|
|
}),
|
2021-11-16 16:10:49 +00:00
|
|
|
handleActionPress: (message: IMessageItem) => RocketChat.toggleStarMessage(message._id, message.starred)
|
2019-05-10 17:09:07 +00:00
|
|
|
},
|
|
|
|
// Pinned Messages Screen
|
|
|
|
Pinned: {
|
|
|
|
name: I18n.t('Pinned'),
|
2020-07-17 18:59:18 +00:00
|
|
|
fetchFunc: () => {
|
|
|
|
const { messages } = this.state;
|
|
|
|
return RocketChat.getMessages(this.rid, this.t, { pinned: true }, messages.length);
|
|
|
|
},
|
2019-05-10 17:09:07 +00:00
|
|
|
noDataMsg: I18n.t('No_pinned_messages'),
|
|
|
|
testID: 'pinned-messages-view',
|
2021-11-16 16:10:49 +00:00
|
|
|
renderItem: (item: IMessageItem) => (
|
2022-03-02 14:18:01 +00:00
|
|
|
// @ts-ignore TODO: unify IMessage
|
2021-09-13 20:41:05 +00:00
|
|
|
<Message {...renderItemCommonProps(item)} msg={item.msg} onLongPress={() => this.onLongPress(item)} theme={theme} />
|
2019-05-10 17:09:07 +00:00
|
|
|
),
|
2020-06-15 19:35:45 +00:00
|
|
|
action: () => ({ title: I18n.t('Unpin'), icon: 'pin', onPress: this.handleActionPress }),
|
2021-11-16 16:10:49 +00:00
|
|
|
handleActionPress: (message: IMessageItem) => RocketChat.togglePinMessage(message._id, message.pinned)
|
2019-05-10 17:09:07 +00:00
|
|
|
}
|
2021-11-16 16:10:49 +00:00
|
|
|
// @ts-ignore
|
2021-09-13 20:41:05 +00:00
|
|
|
}[name];
|
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
load = async () => {
|
|
|
|
const { messages, total, loading } = this.state;
|
2019-05-10 17:09:07 +00:00
|
|
|
if (messages.length === total || loading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({ loading: true });
|
|
|
|
|
|
|
|
try {
|
|
|
|
const result = await this.content.fetchFunc();
|
|
|
|
if (result.success) {
|
|
|
|
this.setState({
|
|
|
|
messages: [...messages, ...result.messages],
|
|
|
|
total: result.total,
|
|
|
|
loading: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
this.setState({ loading: false });
|
|
|
|
console.warn('MessagesView -> catch -> error', error);
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
getCustomEmoji = (name: string) => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { customEmojis } = this.props;
|
|
|
|
const emoji = customEmojis[name];
|
|
|
|
if (emoji) {
|
|
|
|
return emoji;
|
|
|
|
}
|
|
|
|
return null;
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-09-16 20:26:32 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
showAttachment = (attachment: any) => {
|
2020-06-15 14:00:46 +00:00
|
|
|
const { navigation } = this.props;
|
|
|
|
navigation.navigate('AttachmentView', { attachment });
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-20 20:43:50 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
onLongPress = (message: IMessageItem) => {
|
2020-06-15 19:35:45 +00:00
|
|
|
this.setState({ message }, this.showActionSheet);
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
|
|
|
showActionSheet = () => {
|
2020-06-15 19:35:45 +00:00
|
|
|
const { message } = this.state;
|
|
|
|
const { showActionSheet } = this.props;
|
|
|
|
showActionSheet({ options: [this.content.action(message)], hasCancel: true });
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
handleActionPress = async () => {
|
2020-06-15 19:35:45 +00:00
|
|
|
const { message } = this.state;
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2020-06-15 19:35:45 +00:00
|
|
|
try {
|
|
|
|
const result = await this.content.handleActionPress(message);
|
|
|
|
if (result.success) {
|
2021-11-16 16:10:49 +00:00
|
|
|
this.setState((prevState: IMessagesViewState) => ({
|
|
|
|
messages: prevState.messages.filter((item: IMessageItem) => item._id !== message._id),
|
2020-06-15 19:35:45 +00:00
|
|
|
total: prevState.total - 1
|
|
|
|
}));
|
2019-05-10 17:09:07 +00:00
|
|
|
}
|
2020-06-15 19:35:45 +00:00
|
|
|
} catch {
|
|
|
|
// Do nothing
|
2019-05-10 17:09:07 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
setFileLoading = (fileLoading: boolean) => {
|
2019-08-26 16:56:39 +00:00
|
|
|
this.setState({ fileLoading });
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-08-26 16:56:39 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
renderEmpty = () => {
|
|
|
|
const { theme } = this.props;
|
|
|
|
return (
|
2021-09-13 20:41:05 +00:00
|
|
|
<View style={[styles.listEmptyContainer, { backgroundColor: themes[theme].backgroundColor }]} testID={this.content.testID}>
|
2019-12-04 16:39:53 +00:00
|
|
|
<Text style={[styles.noDataFound, { color: themes[theme].titleText }]}>{this.content.noDataMsg}</Text>
|
|
|
|
</View>
|
|
|
|
);
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-05-10 17:09:07 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
renderItem = ({ item }: { item: IMessageItem }) => this.content.renderItem(item);
|
2019-05-10 17:09:07 +00:00
|
|
|
|
|
|
|
render() {
|
2019-12-18 21:13:11 +00:00
|
|
|
const { messages, loading } = this.state;
|
|
|
|
const { theme } = this.props;
|
2019-05-10 17:09:07 +00:00
|
|
|
|
|
|
|
if (!loading && messages.length === 0) {
|
|
|
|
return this.renderEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-09-13 20:41:05 +00:00
|
|
|
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }} testID={this.content.testID}>
|
2020-10-30 13:59:44 +00:00
|
|
|
<StatusBar />
|
2019-05-10 17:09:07 +00:00
|
|
|
<FlatList
|
|
|
|
data={messages}
|
|
|
|
renderItem={this.renderItem}
|
2019-12-04 16:39:53 +00:00
|
|
|
style={[styles.list, { backgroundColor: themes[theme].backgroundColor }]}
|
2019-05-10 17:09:07 +00:00
|
|
|
keyExtractor={item => item._id}
|
|
|
|
onEndReached={this.load}
|
2019-12-04 16:39:53 +00:00
|
|
|
ListFooterComponent={loading ? <ActivityIndicator theme={theme} /> : null}
|
2019-05-10 17:09:07 +00:00
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2021-11-16 16:10:49 +00:00
|
|
|
const mapStateToProps = (state: any) => ({
|
2020-02-11 14:09:14 +00:00
|
|
|
baseUrl: state.server.server,
|
|
|
|
user: getUserSelector(state),
|
2020-08-26 14:06:14 +00:00
|
|
|
customEmojis: state.customEmojis,
|
2021-05-26 17:24:54 +00:00
|
|
|
useRealName: state.settings.UI_Use_Real_Name,
|
|
|
|
isMasterDetail: state.app.isMasterDetail
|
2019-08-07 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
2020-06-15 19:35:45 +00:00
|
|
|
export default connect(mapStateToProps)(withTheme(withActionSheet(MessagesView)));
|