Skip to content

don't show user while searching #4647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2021
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,36 @@ function isSearchStringMatch(searchValue, searchText, participantNames = new Set
});
}

/**
* Returns the given userDetails is currentUser or not.
* @param {Object} userDetails
* @returns {Bool}
*/

function isCurrentUser(userDetails) {
if (!userDetails) {
// If userDetails is null or undefined
return false;
}

// If user login is mobile number, append sms domain if not appended already just a fail safe.
const userDetailsLogin = addSMSDomainIfPhoneNumber(userDetails.login);

// Initial check with currentUserLogin
let result = currentUserLogin.toLowerCase() === userDetailsLogin.toLowerCase();
const loginList = _.isEmpty(currentUser) ? [] : currentUser.loginList;
let index = 0;

// Checking userDetailsLogin against to current user login options.
while (index < loginList.length && !result) {
if (loginList[index].partnerUserID.toLowerCase() === userDetailsLogin.toLowerCase()) {
result = true;
}
index++;
}
return result;
Comment on lines +300 to +307
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The while loop is also an odd choice, but as it doesn't affect your changes we can ignore this.

}

/**
* Build the options
*
Expand Down Expand Up @@ -466,6 +496,7 @@ function getOptions(reports, personalDetails, draftComments, activeReportID, {
if (searchValue
&& recentReportOptions.length === 0
&& personalDetailsOptions.length === 0
&& !isCurrentUser({login: searchValue})
&& _.every(selectedOptions, option => option.login !== searchValue)
&& ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue))
&& (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas))
Expand Down Expand Up @@ -722,38 +753,9 @@ function getReportIcons(report, personalDetails) {
.map(item => item.avatar);
}

/**
* Returns the given userDetails is currentUser or not.
* @param {Object} userDetails
* @returns {Bool}
*/

function isCurrentUser(userDetails) {
if (!userDetails) {
// If userDetails is null or undefined
return false;
}

// If user login is mobile number, append sms domain if not appended already just a fail safe.
const userDetailsLogin = addSMSDomainIfPhoneNumber(userDetails.login);

// Initial check with currentUserLogin
let result = currentUserLogin.toLowerCase() === userDetailsLogin.toLowerCase();
const {loginList} = currentUser;
let index = 0;

// Checking userDetailsLogin against to current user login options.
while (index < loginList.length && !result) {
if (loginList[index].partnerUserID.toLowerCase() === userDetailsLogin.toLowerCase()) {
result = true;
}
index++;
}
return result;
}

export {
addSMSDomainIfPhoneNumber,
isCurrentUser,
getSearchOptions,
getNewChatOptions,
getNewGroupOptions,
Expand All @@ -765,5 +767,4 @@ export {
getIOUConfirmationOptionsFromParticipants,
getDefaultAvatar,
getReportIcons,
isCurrentUser,
};