Skip to content
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

Fix: Web -Default avatar is changed when we select/unselect a member in Workspace invitation page #22791

Merged
merged 4 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ function getOptions(
(searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas))
) {
// Generates an optimistic account ID for new users not yet saved in Onyx
const optimisticAccountID = UserUtils.generateAccountID();
const optimisticAccountID = UserUtils.generateAccountID(searchValue);
const personalDetailsExtended = {
...personalDetails,
[optimisticAccountID]: {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PersonalDetailsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function getAccountIDsByLogins(logins) {
const currentDetail = _.find(personalDetails, (detail) => detail.login === login);
if (!currentDetail) {
// generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet
foundAccountIDs.push(UserUtils.generateAccountID());
foundAccountIDs.push(UserUtils.generateAccountID(login));
} else {
foundAccountIDs.push(Number(currentDetail.accountID));
}
Expand Down
9 changes: 4 additions & 5 deletions src/libs/UserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,12 @@ function getSmallSizeAvatar(avatarURL, accountID) {
}

/**
* Generate a random accountID.
* Uses the same approach of 'generateReportID'.
*
* Generate a random accountID base on searchValue.
* @param {String} searchValue
* @returns {Number}
*/
function generateAccountID() {
return Math.floor(Math.random() * 2 ** 21) * 2 ** 32 + Math.floor(Math.random() * 2 ** 32);
function generateAccountID(searchValue) {
return hashText(searchValue, 2 ** 32);
}

export {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ function setAssigneeValue(assignee, assigneeAccountID, shareDestination, isCurre

// Generate optimistic accountID if this is a brand new user account that hasn't been created yet
if (!newAssigneeAccountID) {
newAssigneeAccountID = UserUtils.generateAccountID();
newAssigneeAccountID = UserUtils.generateAccountID(assignee);
}
if (!isCurrentUser) {
let newChat = {};
Expand Down