Skip to content
Closed
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3281,6 +3281,7 @@ const CONST = {
},

AVATAR_SIZE: {
X_X_LARGE: 'xxlarge',
X_LARGE: 'xlarge',
LARGE: 'large',
MEDIUM: 'medium',
Expand Down
2 changes: 2 additions & 0 deletions src/components/AccountSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
errorText: error ?? '',
shouldShowRedDotIndicator: !!error,
errorTextStyle: styles.mt2,
iconFileName: personalDetails?.originalFileName,
...additionalProps,
};
};
Expand Down Expand Up @@ -197,6 +198,7 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
avatarID={currentUserPersonalDetails?.accountID}
source={currentUserPersonalDetails?.avatar}
fallbackIcon={currentUserPersonalDetails.fallbackIcon}
originalFileName={currentUserPersonalDetails.originalFileName}
/>
<View style={[styles.flex1, styles.flexShrink1, styles.flexBasis0, styles.justifyContentCenter, styles.gap1]}>
<View style={[styles.flexRow, styles.gap1]}>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type AvatarProps = {
/** Optional account id if it's user avatar or policy id if it's workspace avatar */
avatarID?: number | string;

/** Used for recognizing and display optimization of letter avatars. */
originalFileName?: string;

/** Test ID for the Avatar component */
testID?: string;
};
Expand All @@ -72,6 +75,7 @@ function Avatar({
name = '',
avatarID,
testID = 'Avatar',
originalFileName,
}: AvatarProps) {
const theme = useTheme();
const styles = useThemeStyles();
Expand All @@ -86,8 +90,8 @@ function Avatar({

const isWorkspace = type === CONST.ICON_TYPE_WORKSPACE;
const userAccountID = isWorkspace ? undefined : (avatarID as number);
const source = isWorkspace ? originalSource : getAvatar({avatarSource: originalSource, accountID: userAccountID, originalFileName, size});

const source = isWorkspace ? originalSource : getAvatar({avatarSource: originalSource, accountID: userAccountID});
let optimizedSource = source;
const maybeDefaultAvatarName = getPresetAvatarNameFromURL(source);

Expand Down
5 changes: 5 additions & 0 deletions src/components/AvatarButtonWithIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ type AvatarButtonWithIconProps = {

/** The name associated with avatar */
name?: string;

/** Original file name. Used for recognizing and display optimization of letter avatars. */
originalFileName?: string;
};

/**
Expand All @@ -86,6 +89,7 @@ function AvatarButtonWithIcon({
editIcon = Expensicons.Pencil,
anchorRef,
name = '',
originalFileName,
}: AvatarButtonWithIconProps) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -115,6 +119,7 @@ function AvatarButtonWithIcon({
size={size}
type={type}
name={name}
originalFileName={originalFileName}
/>
) : (
<DefaultAvatar />
Expand Down
6 changes: 5 additions & 1 deletion src/components/AvatarWithIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ type AvatarWithIndicatorProps = {

/** Indicates whether the avatar is loaded or not */
isLoading?: boolean;

/** Used for recognizing and display optimization of letter avatars. */
originalFileName?: string;
};

function AvatarWithIndicator({source, accountID, tooltipText = '', fallbackIcon = Expensicons.FallbackAvatar, isLoading = true}: AvatarWithIndicatorProps) {
function AvatarWithIndicator({source, accountID, tooltipText = '', fallbackIcon = Expensicons.FallbackAvatar, isLoading = true, originalFileName}: AvatarWithIndicatorProps) {
const styles = useThemeStyles();

return (
Expand All @@ -43,6 +46,7 @@ function AvatarWithIndicator({source, accountID, tooltipText = '', fallbackIcon
fallbackIcon={fallbackIcon}
avatarID={accountID}
type={CONST.ICON_TYPE_AVATAR}
originalFileName={originalFileName}
/>
<Indicator />
</>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ColoredLetterAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ColoredLetterAvatar({component, backgroundColor, fillColor, size = CONS
const avatarSize = StyleUtils.getAvatarSize(size);
return (
<View
style={{width: avatarSize, height: avatarSize, backgroundColor}}
style={{width: avatarSize, height: avatarSize, backgroundColor, borderRadius: '100%'}}
dataSet={{id: 'colored-avatar'}}
>
<ImageSVG
Expand Down
6 changes: 5 additions & 1 deletion src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ type MenuItemBaseProps = {

iconAccountID?: number;

/** Used for display optimization of letter avatars. */
iconFileName?: string;

/** Should we use default cursor for disabled content */
shouldUseDefaultCursorWhenDisabled?: boolean;

Expand Down Expand Up @@ -440,6 +443,7 @@ function MenuItem({
errorTextStyle,
shouldShowRedDotIndicator,
hintText,
iconFileName,
success = false,
iconReportID,
focused = false,
Expand Down Expand Up @@ -654,7 +658,6 @@ function MenuItem({
};

const isIDPassed = !!iconReportID || !!iconAccountID || iconAccountID === CONST.DEFAULT_NUMBER_ID;

return (
<View onBlur={onBlur}>
{!!label && !isLabelHoverable && (
Expand Down Expand Up @@ -799,6 +802,7 @@ function MenuItem({
fallbackIcon={fallbackIcon}
size={avatarSize}
type={CONST.ICON_TYPE_AVATAR}
originalFileName={iconFileName}
/>
)}
{iconType === CONST.ICON_TYPE_PLAID && !!plaidUrl && <PlaidCardFeedIcon plaidUrl={plaidUrl} />}
Expand Down
4 changes: 2 additions & 2 deletions src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ function BasePopoverMenu({
};

const renderedMenuItems = currentMenuItems.map((item, menuIndex) => {
const {text, onSelected, subMenuItems, shouldCallAfterModalHide, key, testID: menuItemTestID, shouldShowLoadingSpinnerIcon, ...menuItemProps} = item;

const {text, onSelected, subMenuItems, shouldCallAfterModalHide, key, testID: menuItemTestID, shouldShowLoadingSpinnerIcon, iconFileName, ...menuItemProps} = item;
return (
<OfflineWithFeedback
// eslint-disable-next-line react/no-array-index-key
Expand All @@ -386,6 +385,7 @@ function BasePopoverMenu({
shouldCheckActionAllowedOnPress={false}
iconRight={item.rightIcon}
shouldShowRightIcon={!!item.rightIcon}
iconFileName={iconFileName}
onFocus={() => {
if (!shouldUpdateFocusedIndex) {
return;
Expand Down
6 changes: 6 additions & 0 deletions src/components/ReportActionAvatars/ReportActionAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function ReportActionAvatarSingle({
fallbackIcon={fallbackIcon}
testID="ReportActionAvatars-SingleAvatar"
reportID={reportID}
originalFileName={avatar?.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down Expand Up @@ -235,6 +236,7 @@ function ReportActionAvatarSubscript({
fallbackIcon={primaryAvatar.fallbackIcon}
testID="ReportActionAvatars-Subscript-MainAvatar"
reportID={reportID}
originalFileName={primaryAvatar.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down Expand Up @@ -265,6 +267,7 @@ function ReportActionAvatarSubscript({
fallbackIcon={secondaryAvatar.fallbackIcon}
testID="ReportActionAvatars-Subscript-SecondaryAvatar"
reportID={reportID}
originalFileName={secondaryAvatar.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down Expand Up @@ -408,6 +411,7 @@ function ReportActionAvatarMultipleHorizontal({
fallbackIcon={icon.fallbackIcon}
testID="ReportActionAvatars-MultipleAvatars-StackedHorizontally-Avatar"
reportID={reportID}
originalFileName={icon?.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down Expand Up @@ -550,6 +554,7 @@ function ReportActionAvatarMultipleDiagonal({
fallbackIcon={icons.at(0)?.fallbackIcon}
testID="ReportActionAvatars-MultipleAvatars-MainAvatar"
reportID={reportID}
originalFileName={icons.at(0)?.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down Expand Up @@ -582,6 +587,7 @@ function ReportActionAvatarMultipleDiagonal({
fallbackIcon={icons.at(1)?.fallbackIcon}
testID="ReportActionAvatars-MultipleAvatars-SecondaryAvatar"
reportID={reportID}
originalFileName={icons.at(1)?.originalFileName}
/>
</View>
</UserDetailsTooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ function useReportActionAvatars({
source: personalDetails?.[id]?.avatar ?? FallbackAvatar,
name: personalDetails?.[id]?.[shouldUseActorAccountID ? 'displayName' : 'login'] ?? invitedEmail ?? '',
fallbackIcon: shouldUseCustomFallbackAvatar ? RandomAvatarUtils.getAvatarForContact(String(id)) : undefined,
originalFileName: personalDetails?.[id]?.originalFileName,
};
});

Expand Down Expand Up @@ -221,6 +222,7 @@ function useReportActionAvatars({
type: CONST.ICON_TYPE_AVATAR,
fill: undefined,
fallbackIcon,
originalFileName: delegatePersonalDetails.displayName,
}
: undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateA
type={icon?.type ?? CONST.ICON_TYPE_AVATAR}
name={icon?.name ?? userLogin}
fallbackIcon={icon?.fallbackIcon}
originalFileName={icon?.originalFileName}
/>
</View>
<Text style={[styles.mt2, styles.textMicroBold, styles.textReactionSenders, styles.textAlignCenter]}>{title}</Text>
Expand Down
6 changes: 6 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@
const parsedReportActionMessageCache: Record<string, string> = {};

let conciergeReportID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 953 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportID = value;
Expand All @@ -958,7 +958,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 961 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -976,7 +976,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 979 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (currentUserAccountID) {
Expand All @@ -988,14 +988,14 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 991 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 998 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand All @@ -1010,7 +1010,7 @@

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1013 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1048,14 +1048,14 @@
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({

Check warning on line 1051 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1058 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1081,7 +1081,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1084 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -1094,7 +1094,7 @@

let allReportMetadata: OnyxCollection<ReportMetadata>;
const allReportMetadataKeyValue: Record<string, ReportMetadata> = {};
Onyx.connect({

Check warning on line 1097 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_METADATA,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -3019,6 +3019,7 @@
type: CONST.ICON_TYPE_AVATAR,
name: displayNameLogin ?? '',
fallbackIcon: personalDetails?.[accountID]?.fallbackIcon ?? '',
originalFileName: personalDetails?.[accountID]?.originalFileName,
};
avatars.push(userIcon);
}
Expand Down Expand Up @@ -3345,6 +3346,7 @@
type: CONST.ICON_TYPE_AVATAR,
name: displayName,
fallbackIcon: details?.fallbackIcon,
originalFileName: details?.originalFileName,
};
}

Expand Down Expand Up @@ -3390,6 +3392,7 @@
type: CONST.ICON_TYPE_AVATAR,
name: actorDetails?.displayName ?? '',
fallbackIcon: actorDetails?.fallbackIcon,
originalFileName: actorDetails?.originalFileName,
};
return [memberIcon, workspaceIcon];
}
Expand All @@ -3411,6 +3414,7 @@
name: formatPhoneNumber(actorDisplayName),
type: CONST.ICON_TYPE_AVATAR,
fallbackIcon: actorDetails?.fallbackIcon,
originalFileName: actorDetails?.originalFileName,
};

if (isWorkspaceThread(report)) {
Expand Down Expand Up @@ -3506,13 +3510,15 @@
type: CONST.ICON_TYPE_AVATAR,
name: managerDetails?.displayName ?? '',
fallbackIcon: managerDetails?.fallbackIcon,
originalFileName: managerDetails?.originalFileName,
};
const ownerIcon = {
id: report?.ownerAccountID,
source: ownerDetails?.avatar ?? FallbackAvatar,
type: CONST.ICON_TYPE_AVATAR,
name: ownerDetails?.displayName ?? '',
fallbackIcon: ownerDetails?.fallbackIcon,
originalFileName: ownerDetails?.originalFileName,
};
const isManager = currentUserAccountID === report?.managerID;

Expand Down
Loading
Loading