-
Notifications
You must be signed in to change notification settings - Fork 3k
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: Avatar changes when from offline to online #32090
Conversation
Thanks! I'll take a look tomorrow. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-native-2023-11-27_12.03.43.mp4Android: mWeb Chromeandroid-chrome-2023-11-27_11.57.58.mp4iOS: Nativeios-native-2023-11-27_15.32.09.mp4iOS: mWeb Safariios-safari-2023-11-27_15.28.54.mp4MacOS: Chrome / Safaridesktop-chrome-2023-11-27_11.53.04.mp4MacOS: Desktopdesktop-app-2023-11-27_15.34.25.mp4 |
@anyongjitiger As I mentioned on the previous PR, please link to the issue itself next to the $, rather than your proposal. |
@anyongjitiger Just tested this case that you mentioned on the closed PR, but it doesn't seem to work: desktop-chrome-remove-avatar-2023-11-29_15.43.20.mp4 |
src/libs/UserUtils.ts
Outdated
const accountIDHashBucket = ((accountID % CONST.DEFAULT_AVATAR_COUNT) + 1) as AvatarRange; | ||
|
||
let accountIDHashBucket: AvatarRange; | ||
if (avatarURL && /images\/avatars\/default-avatar_\d+\./.test(avatarURL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm convinced this can be tidied up 😉 Let's only use one regex pattern and we probably don't need to test for it first if we're going to match
later anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I have removed it.
src/libs/UserUtils.ts
Outdated
const accountIDHashBucket = ((accountID % CONST.DEFAULT_AVATAR_COUNT) + 1) as AvatarRange; | ||
|
||
let accountIDHashBucket: AvatarRange; | ||
if (avatarURL && /images\/avatars\/default-avatar_\d+\./.test(avatarURL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add an explanatory comment here as it won't be super clear why we're extracting the ID from avatarURL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added
src/libs/UserUtils.ts
Outdated
if (Number(accountID) === CONST.ACCOUNT_ID.CONCIERGE) { | ||
return CONST.CONCIERGE_ICON_URL; | ||
} | ||
|
||
let email; let originAccountID; | ||
if (allPersonalDetails?.[accountID]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment also needed here to explain why this code is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added
merge from origin branch
@jjcoffee comment: |
App/src/libs/actions/PersonalDetails.ts Lines 520 to 521 in 132199c
@anyongjitiger Looking into this a bit more, this was introduced in this PR, it's possible that I misunderstood the code and actually it's correct for the default to be |
@anyongjitiger Great, thanks! To clarify, is that with reverting the default Can you also address my other comments? |
No, it's |
Okay I've tested and I don't see any issues in oldDot when deleting a custom avatar (even when the avatar ID exceeds Please can you also update the linked issue in the description (after the |
src/libs/UserUtils.ts
Outdated
if (allPersonalDetails?.[accountID]) { | ||
if (allPersonalDetails[accountID].login) { | ||
email = allPersonalDetails[accountID].login; | ||
} else if (allPersonalDetails[accountID].displayName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how useful this is, since the displayName could have changed and may no longer be an email?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have already updated my PR. Thank you.
src/libs/UserUtils.ts
Outdated
} | ||
} | ||
if (email) { | ||
originAccountID = generateAccountID(email); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand right, I think this would clearer if it was named originalOptimisticAccountID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have updated it to originalOptimisticAccountID.
src/libs/UserUtils.ts
Outdated
|
||
// When we create a chat with a new user, an optimistic ID is used, and the avatar is generated based on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the comment more concise, it's a bit too long I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have updated the comment.
@jjcoffee |
Thanks! Code is looking good, I will just give it a retest tomorrow and then we should be good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests well, LGTM!
@anyongjitiger Sorry just noticed you left a trailing |
@Julesssss All yours! |
Onyx.connect({ | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
callback: (val) => (allPersonalDetails = _.isEmpty(val) ? {} : val), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid this pattern.
ref: https://expensify.slack.com/archives/C01GTK53T8Q/p1688630003862989
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link doesn't work for me for some reason 😅 Can you post some more detail here maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump on this question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Managed to get the link to load by pasting it into a chat with myself on Slack! 😆
As far as I can tell we aren't memoizing any of the calls to getDefaultAvatarURL
so I don't think the issue is particularly relevant here. Many of the calls to getDefaultAvatarURL
are also from ReportUtils
which also uses this pattern so it wouldn't be a very useful optimization 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Julesssss Friendly bump on the above - I think we should be good to merge!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/Julesssss in version: 1.4.14-0 🚀
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 1.4.14-0 🚀
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.4.14-6 🚀
|
// But the avatar link still corresponds to the original ID-generated link. So we extract the SVG image number from the backend's link instead of using the user ID directly | ||
let accountIDHashBucket: AvatarRange; | ||
if (avatarURL) { | ||
const match = avatarURL.match(/(?<=default-avatar_)\d+(?=\.)/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have one more default avatar prefix avatar_
which is missed here, that caused a regression more details here
Details
Fixed Issues
$ #28518
PROPOSAL: #28518 (comment)
Tests
Offline tests
Same as QA steps
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.native.mp4
Android: mWeb Chrome
android.web.mp4
iOS: Native
ios.native.-.01.mp4
iOS: mWeb Safari
ios.web.-.01.mp4
MacOS: Chrome / Safari
chrome.mp4
MacOS: Desktop
desktop.mp4