-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 not changed in tooltip when updating avatar #20713
Changes from 4 commits
270ce3b
2283c67
e41f473
9676093
14e8999
1c3a20d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -379,6 +379,7 @@ function updateAvatar(file) { | |||||||
}, | ||||||||
}, | ||||||||
]; | ||||||||
|
||||||||
const successData = [ | ||||||||
{ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
|
@@ -408,6 +409,48 @@ function updateAvatar(file) { | |||||||
}, | ||||||||
]; | ||||||||
|
||||||||
const accountID = lodashGet(personalDetails, [currentUserEmail, 'accountID'], ''); | ||||||||
if (accountID) { | ||||||||
optimisticData.push({ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||||||||
value: { | ||||||||
[accountID]: { | ||||||||
avatar: file.uri, | ||||||||
errorFields: { | ||||||||
avatar: null, | ||||||||
}, | ||||||||
pendingFields: { | ||||||||
avatar: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
}); | ||||||||
successData.push({ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||||||||
value: { | ||||||||
[accountID]: { | ||||||||
pendingFields: { | ||||||||
avatar: null, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
}); | ||||||||
failureData.push({ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||||||||
value: { | ||||||||
[accountID]: { | ||||||||
avatar: personalDetails[currentUserEmail].avatar, | ||||||||
pendingFields: { | ||||||||
avatar: null, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
}); | ||||||||
} | ||||||||
|
||||||||
API.write('UpdateUserAvatar', {file}, {optimisticData, successData, failureData}); | ||||||||
} | ||||||||
|
||||||||
|
@@ -416,36 +459,54 @@ function updateAvatar(file) { | |||||||
*/ | ||||||||
function deleteAvatar() { | ||||||||
// We want to use the old dot avatar here as this affects both platforms. | ||||||||
const defaultAvatar = UserUtils.getDefaultAvatarURL(currentUserEmail); | ||||||||
const defaultAvatar = UserUtils.getDefaultAvatarURL(currentUserEmail, true); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @s-alves10 Let's not try to change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If set to false, default user avatar URL is different than the ones that are current using. When user removes avatar, there is an inconsistency. You can easily check that. Please let me know if you still want to change it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see the in-consistency, but why does it happen for the avatar in the tooltip and not with avatars elsewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other avatars get avatar URL with the below function. Lines 150 to 152 in 0a471b0
This function corrects this error, but it seems redundant. I think the current change doesn't affect this function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use this function inside our tooltip like we are using elsewhere? This will prevent us from using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @s-alves10 Any update on above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome. Thanks! |
||||||||
|
||||||||
API.write( | ||||||||
'DeleteUserAvatar', | ||||||||
{}, | ||||||||
const optimisticData = [ | ||||||||
{ | ||||||||
optimisticData: [ | ||||||||
{ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS, | ||||||||
value: { | ||||||||
[currentUserEmail]: { | ||||||||
avatar: defaultAvatar, | ||||||||
}, | ||||||||
}, | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS, | ||||||||
value: { | ||||||||
[currentUserEmail]: { | ||||||||
avatar: defaultAvatar, | ||||||||
}, | ||||||||
], | ||||||||
failureData: [ | ||||||||
{ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS, | ||||||||
value: { | ||||||||
[currentUserEmail]: { | ||||||||
avatar: personalDetails[currentUserEmail].avatar, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
}, | ||||||||
]; | ||||||||
const failureData = [ | ||||||||
{ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS, | ||||||||
value: { | ||||||||
[currentUserEmail]: { | ||||||||
avatar: personalDetails[currentUserEmail].avatar, | ||||||||
}, | ||||||||
], | ||||||||
}, | ||||||||
}, | ||||||||
); | ||||||||
]; | ||||||||
|
||||||||
const accountID = lodashGet(personalDetails, [currentUserEmail, 'accountID'], ''); | ||||||||
if (accountID) { | ||||||||
optimisticData.push({ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||||||||
value: { | ||||||||
[personalDetails[currentUserEmail].accountID]: { | ||||||||
avatar: defaultAvatar, | ||||||||
}, | ||||||||
}, | ||||||||
}); | ||||||||
failureData.push({ | ||||||||
onyxMethod: Onyx.METHOD.MERGE, | ||||||||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||||||||
value: { | ||||||||
[personalDetails[currentUserEmail].accountID]: { | ||||||||
avatar: personalDetails[currentUserEmail].avatar, | ||||||||
}, | ||||||||
}, | ||||||||
}); | ||||||||
} | ||||||||
|
||||||||
API.write('DeleteUserAvatar', {}, {optimisticData, failureData}); | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
|
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.
Not needed.