From 17d8905782d7fc9f6ea8e4096f235fda0eaf73ee Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Tue, 13 Feb 2024 16:26:49 -0300 Subject: [PATCH 1/3] making avatarurl be only accountID based --- src/libs/UserUtils.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index 52c3ecef156c..18e440b0e05f 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -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`; From f90280b7c163c1b208b23d62875843eaf9d2701f Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Tue, 13 Feb 2024 17:03:33 -0300 Subject: [PATCH 2/3] removed unused allPersonalDetails variable --- src/libs/UserUtils.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index 18e440b0e05f..0d16fa35504c 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -18,12 +18,6 @@ type AvatarSource = IconAsset | string; type LoginListIndicator = ValueOf | ''; -let allPersonalDetails: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - callback: (val) => (allPersonalDetails = _.isEmpty(val) ? {} : val), -}); - /** * Searches through given loginList for any contact method / login with an error. * From f13db5d61e444a2af2a557bc180230d9586a7596 Mon Sep 17 00:00:00 2001 From: Rodrigo Lino da Costa Date: Tue, 13 Feb 2024 17:12:22 -0300 Subject: [PATCH 3/3] removing more unused code --- src/libs/UserUtils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index 0d16fa35504c..652bf201ca6d 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -1,13 +1,9 @@ import Str from 'expensify-common/lib/str'; -import _ from 'lodash'; import type {OnyxEntry} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import * as defaultAvatars from '@components/Icon/DefaultAvatars'; import {ConciergeAvatar, FallbackAvatar} from '@components/Icon/Expensicons'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {PersonalDetailsList} from '@src/types/onyx'; import type Login from '@src/types/onyx/Login'; import type IconAsset from '@src/types/utils/IconAsset'; import hashCode from './hashCode';