Skip to content

Commit f225936

Browse files
authored
Merge pull request #22791 from dukenv0307/fix/22085
Fix: Web -Default avatar is changed when we select/unselect a member in Workspace invitation page
2 parents 0a24c6c + ffde4e4 commit f225936

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

src/libs/OptionsListUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ function getOptions(
806806
(searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas))
807807
) {
808808
// Generates an optimistic account ID for new users not yet saved in Onyx
809-
const optimisticAccountID = UserUtils.generateAccountID();
809+
const optimisticAccountID = UserUtils.generateAccountID(searchValue);
810810
const personalDetailsExtended = {
811811
...personalDetails,
812812
[optimisticAccountID]: {

src/libs/PersonalDetailsUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function getAccountIDsByLogins(logins) {
6161
const currentDetail = _.find(personalDetails, (detail) => detail.login === login);
6262
if (!currentDetail) {
6363
// generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet
64-
foundAccountIDs.push(UserUtils.generateAccountID());
64+
foundAccountIDs.push(UserUtils.generateAccountID(login));
6565
} else {
6666
foundAccountIDs.push(Number(currentDetail.accountID));
6767
}

src/libs/UserUtils.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,12 @@ function getSmallSizeAvatar(avatarURL, accountID) {
207207
}
208208

209209
/**
210-
* Generate a random accountID.
211-
* Uses the same approach of 'generateReportID'.
212-
*
210+
* Generate a random accountID base on searchValue.
211+
* @param {String} searchValue
213212
* @returns {Number}
214213
*/
215-
function generateAccountID() {
216-
return Math.floor(Math.random() * 2 ** 21) * 2 ** 32 + Math.floor(Math.random() * 2 ** 32);
214+
function generateAccountID(searchValue) {
215+
return hashText(searchValue, 2 ** 32);
217216
}
218217

219218
export {

src/libs/actions/Task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ function setAssigneeValue(assignee, assigneeAccountID, shareDestination, isCurre
498498

499499
// Generate optimistic accountID if this is a brand new user account that hasn't been created yet
500500
if (!newAssigneeAccountID) {
501-
newAssigneeAccountID = UserUtils.generateAccountID();
501+
newAssigneeAccountID = UserUtils.generateAccountID(assignee);
502502
}
503503
if (!isCurrentUser) {
504504
let newChat = {};

0 commit comments

Comments
 (0)