From 42df5ddbc1d81b1d6aaa788e45bdc8f4edc3354a Mon Sep 17 00:00:00 2001 From: Rohit Verma <44283521+refactor-droidyy@users.noreply.github.com> Date: Sat, 18 Jul 2020 00:29:18 +0530 Subject: [PATCH] [FIX] MessagesView duplicating content (#2307) * Fix Pagination duplicacy * Fix MessageView Duplicate Content * [FIX] Return fetch func Co-authored-by: Djorkaeff Alexandre --- app/views/MessagesView/index.js | 38 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/app/views/MessagesView/index.js b/app/views/MessagesView/index.js index c01b63c2..1a55b72f 100644 --- a/app/views/MessagesView/index.js +++ b/app/views/MessagesView/index.js @@ -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 => (