[FIX] MessagesView duplicating content (#2307)

* Fix Pagination duplicacy

* Fix MessageView Duplicate Content

* [FIX] Return fetch func

Co-authored-by: Djorkaeff Alexandre <djorkaeff.unb@gmail.com>
This commit is contained in:
Rohit Verma 2020-07-18 00:29:18 +05:30 committed by GitHub
parent 52b82e5809
commit 42df5ddbc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 15 deletions

View File

@ -78,9 +78,7 @@ class MessagesView extends React.Component {
}
defineMessagesViewContent = (name) => {
const { messages } = this.state;
const { user, baseUrl, theme } = this.props;
const renderItemCommonProps = item => ({
item,
baseUrl,
@ -101,6 +99,7 @@ class MessagesView extends React.Component {
Files: {
name: I18n.t('Files'),
fetchFunc: async() => {
const { messages } = this.state;
const result = await RocketChat.getFiles(this.rid, this.t, messages.length);
return { ...result, messages: result.files };
},
@ -125,12 +124,15 @@ class MessagesView extends React.Component {
// Mentions Messages Screen
Mentions: {
name: I18n.t('Mentions'),
fetchFunc: () => RocketChat.getMessages(
this.rid,
this.t,
{ 'mentions._id': { $in: [user.id] } },
messages.length
),
fetchFunc: () => {
const { messages } = this.state;
return RocketChat.getMessages(
this.rid,
this.t,
{ 'mentions._id': { $in: [user.id] } },
messages.length
);
},
noDataMsg: I18n.t('No_mentioned_messages'),
testID: 'mentioned-messages-view',
renderItem: item => (
@ -144,12 +146,15 @@ class MessagesView extends React.Component {
// Starred Messages Screen
Starred: {
name: I18n.t('Starred'),
fetchFunc: () => RocketChat.getMessages(
this.rid,
this.t,
{ 'starred._id': { $in: [user.id] } },
messages.length
),
fetchFunc: () => {
const { messages } = this.state;
return RocketChat.getMessages(
this.rid,
this.t,
{ 'starred._id': { $in: [user.id] } },
messages.length
);
},
noDataMsg: I18n.t('No_starred_messages'),
testID: 'starred-messages-view',
renderItem: item => (
@ -166,7 +171,10 @@ class MessagesView extends React.Component {
// Pinned Messages Screen
Pinned: {
name: I18n.t('Pinned'),
fetchFunc: () => RocketChat.getMessages(this.rid, this.t, { pinned: true }, messages.length),
fetchFunc: () => {
const { messages } = this.state;
return RocketChat.getMessages(this.rid, this.t, { pinned: true }, messages.length);
},
noDataMsg: I18n.t('No_pinned_messages'),
testID: 'pinned-messages-view',
renderItem: item => (