Skip to content

Commit

Permalink
Merge pull request #4647 from aman-atg/aman-atg-dontShowUserOnSearch
Browse files Browse the repository at this point in the history
don't show user while searching
  • Loading branch information
Julesssss authored Aug 19, 2021
2 parents 0d263e5 + 1ae25f2 commit 064e582
Showing 1 changed file with 32 additions and 31 deletions.
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) || _.isEmpty(currentUser.loginList) ? [] : 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;
}

/**
* Build the options
*
Expand Down Expand Up @@ -476,6 +506,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))
&& (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === searchValue))
Expand Down Expand Up @@ -751,38 +782,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 @@ -794,5 +796,4 @@ export {
getIOUConfirmationOptionsFromParticipants,
getDefaultAvatar,
getReportIcons,
isCurrentUser,
};

0 comments on commit 064e582

Please sign in to comment.