From f065fe574435d058729cd40c750f804e7d87e7a7 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 3 Mar 2022 01:01:47 +0530 Subject: [PATCH 1/3] Remove duplicates from the new Group page --- src/pages/NewChatPage.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index deac11a5646..9349325d68e 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -108,17 +108,21 @@ class NewChatPage extends Component { } } + const filterText = _.reduce(this.state.selectedOptions, (str, {login}) => `${str} ${login}`, ''); + const recentReportsWithoutSelected = _.filter(this.state.recentReports, ({login}) => !filterText.includes(login)); + const personalDetailsWithoutSelected = _.filter(this.state.personalDetails, ({login}) => !filterText.includes(login)); + sections.push({ title: this.props.translate('common.recents'), - data: this.state.recentReports, - shouldShow: !_.isEmpty(this.state.recentReports), + data: recentReportsWithoutSelected, + shouldShow: !_.isEmpty(recentReportsWithoutSelected), indexOffset: _.reduce(sections, (prev, {data}) => prev + data.length, 0), }); sections.push({ title: this.props.translate('common.contacts'), - data: this.state.personalDetails, - shouldShow: !_.isEmpty(this.state.personalDetails), + data: personalDetailsWithoutSelected, + shouldShow: !_.isEmpty(personalDetailsWithoutSelected), indexOffset: _.reduce(sections, (prev, {data}) => prev + data.length, 0), }); @@ -176,7 +180,7 @@ class NewChatPage extends Component { this.props.personalDetails, this.props.betas, prevState.searchValue, - newSelectedOptions, + [], this.excludedGroupEmails, ); From b122d179ccf44ca9ee138267f4416bf46477afbe Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 3 Mar 2022 01:03:00 +0530 Subject: [PATCH 2/3] Remove duplicates from the WorkspaceInvitePage --- src/pages/workspace/WorkspaceInvitePage.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 687b49e215f..8da825cc53c 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -138,10 +138,13 @@ class WorkspaceInvitePage extends React.Component { indexOffset: 0, }); + const filterText = _.reduce(this.state.selectedOptions, (str, {login}) => `${str} ${login}`, ''); + const personalDetailsWithoutSelected = _.filter(this.state.personalDetails, ({login}) => !filterText.includes(login)); + sections.push({ title: this.props.translate('common.contacts'), - data: this.state.personalDetails, - shouldShow: !_.isEmpty(this.state.personalDetails), + data: personalDetailsWithoutSelected, + shouldShow: !_.isEmpty(personalDetailsWithoutSelected), indexOffset: _.reduce(sections, (prev, {data}) => prev + data.length, 0), }); @@ -192,7 +195,7 @@ class WorkspaceInvitePage extends React.Component { this.props.personalDetails, this.props.betas, prevState.searchValue, - newSelectedOptions, + [], this.getExcludedUsers(), ); From ec1b0fa146b1f178708c96b72b85f5d6ac491196 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 3 Mar 2022 03:05:14 +0530 Subject: [PATCH 3/3] Add comments --- src/pages/NewChatPage.js | 1 + src/pages/workspace/WorkspaceInvitePage.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/NewChatPage.js b/src/pages/NewChatPage.js index 9349325d68e..679b655c26d 100755 --- a/src/pages/NewChatPage.js +++ b/src/pages/NewChatPage.js @@ -108,6 +108,7 @@ class NewChatPage extends Component { } } + // Filtering out selected users from the search results const filterText = _.reduce(this.state.selectedOptions, (str, {login}) => `${str} ${login}`, ''); const recentReportsWithoutSelected = _.filter(this.state.recentReports, ({login}) => !filterText.includes(login)); const personalDetailsWithoutSelected = _.filter(this.state.personalDetails, ({login}) => !filterText.includes(login)); diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 8da825cc53c..c6f837450da 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -138,6 +138,7 @@ class WorkspaceInvitePage extends React.Component { indexOffset: 0, }); + // Filtering out selected users from the search results const filterText = _.reduce(this.state.selectedOptions, (str, {login}) => `${str} ${login}`, ''); const personalDetailsWithoutSelected = _.filter(this.state.personalDetails, ({login}) => !filterText.includes(login));