Skip to content

Commit

Permalink
Merge pull request #7986 from parasharrajat/optionSelectorPages
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam committed Mar 3, 2022
2 parents 1d57b79 + ec1b0fa commit 692f92d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
15 changes: 10 additions & 5 deletions src/pages/NewChatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,22 @@ 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));

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),
});

Expand Down Expand Up @@ -176,7 +181,7 @@ class NewChatPage extends Component {
this.props.personalDetails,
this.props.betas,
prevState.searchValue,
newSelectedOptions,
[],
this.excludedGroupEmails,
);

Expand Down
10 changes: 7 additions & 3 deletions src/pages/workspace/WorkspaceInvitePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ 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));

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),
});

Expand Down Expand Up @@ -192,7 +196,7 @@ class WorkspaceInvitePage extends React.Component {
this.props.personalDetails,
this.props.betas,
prevState.searchValue,
newSelectedOptions,
[],
this.getExcludedUsers(),
);

Expand Down

0 comments on commit 692f92d

Please sign in to comment.