Skip to content

Commit

Permalink
Merge pull request #15185 from Expensify/marcaaron-fixAvatarImage
Browse files Browse the repository at this point in the history
Fix avatar preview size
  • Loading branch information
puneetlath authored Feb 17, 2023
2 parents 7805b90 + bd7e964 commit 623162d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ function isDefaultAvatar(avatarURL) {
*
* @param {String} [avatarURL] - the avatar source from user's personalDetails
* @param {String} [login] - the email of the user
* @returns {String | Function}
* @returns {String|Function}
*/
function getAvatar(avatarURL, login) {
if (isDefaultAvatar(avatarURL)) {
Expand All @@ -515,6 +515,22 @@ function getAvatar(avatarURL, login) {
return avatarURL;
}

/**
* Avatars uploaded by users will have a _128 appended so that the asset server returns a small version.
* This removes that part of the URL so the full version of the image can load.
*
* @param {String} [avatarURL]
* @param {String} [login]
* @returns {String|Function}
*/
function getFullSizeAvatar(avatarURL, login) {
const source = getAvatar(avatarURL, login);
if (!_.isString(source)) {
return source;
}
return source.replace('_128', '');
}

/**
* Returns the appropriate icons for the given chat report using the stored personalDetails.
* The Avatar sources can be URLs or Icon components according to the chat type.
Expand Down Expand Up @@ -1571,5 +1587,6 @@ export {
canSeeDefaultRoom,
getCommentLength,
openReportFromDeepLink,
getFullSizeAvatar,
getIOUOptions,
};
2 changes: 1 addition & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DetailsPage extends React.PureComponent {
<View style={styles.avatarSectionWrapper}>
<AttachmentModal
headerTitle={isSMSLogin ? this.props.toLocalPhone(details.displayName) : details.displayName}
source={ReportUtils.getAvatar(details.avatar, details.login)}
source={ReportUtils.getFullSizeAvatar(details.avatar, details.login)}
isAuthTokenRequired
>
{({show}) => (
Expand Down

0 comments on commit 623162d

Please sign in to comment.