Skip to content

Commit

Permalink
making avatarurl be only accountID based
Browse files Browse the repository at this point in the history
  • Loading branch information
rlinoz committed Feb 13, 2024
1 parent a3943ac commit 17d8905
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libs/UserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,15 @@ function getDefaultAvatar(accountID = -1, avatarURL?: string): IconAsset {
}

/**
* Helper method to return default avatar URL associated with login
* Helper method to return default avatar URL associated with the accountID
*/
function getDefaultAvatarURL(accountID: string | number = ''): string {
if (Number(accountID) === CONST.ACCOUNT_ID.CONCIERGE) {
return CONST.CONCIERGE_ICON_URL;
}
// To ensure that the avatar remains unchanged and matches the one returned by the backend,
// utilize an optimistic ID generated from the email instead of directly using the user ID.
const email = allPersonalDetails?.[accountID]?.login;
const originalOptimisticAccountID = email ? generateAccountID(email) : accountID;

// Note that Avatar count starts at 1 which is why 1 has to be added to the result (or else 0 would result in a broken avatar link)
const accountIDHashBucket = (Number(originalOptimisticAccountID) % CONST.DEFAULT_AVATAR_COUNT) + 1;
const accountIDHashBucket = (Number(accountID) % CONST.DEFAULT_AVATAR_COUNT) + 1;
const avatarPrefix = `default-avatar`;

return `${CONST.CLOUDFRONT_URL}/images/avatars/${avatarPrefix}_${accountIDHashBucket}.png`;
Expand Down

0 comments on commit 17d8905

Please sign in to comment.