Refactor PersonalDetails_Update with a few new commands#9696
Conversation
PersonalDetails_UpdatePersonalDetails_Update
PersonalDetails_UpdatePersonalDetails_Update
|
The App PR we were waiting on has been merged into |
|
Seems like Travis is not happy 😁 |
|
Can we get a few screenshots? |
|
This should be on HOLD until the Web counterpart merges, right? |
PersonalDetails_UpdatePersonalDetails_Update
|
Put on hold :D Dang travis!! And ya.... Videos are good... But... annoying to make... but will do :D |
|
@Beamanator So I see it in your videos as well, but it is expected we wont update the details for the user automatically? For example, I feel like it is confusing that I have updated the name and then I go back to the settings but the name is not updated yet, I need to refresh or close settings and go back to the profile settings which updates the name in UI as well |
| optimisticData: [{ | ||
| onyxMethod: CONST.ONYX.METHOD.MERGE, | ||
| key: ONYXKEYS.PERSONAL_DETAILS, | ||
| value: { | ||
| [currentUserEmail]: { | ||
| firstName, | ||
| lastName, | ||
| pronouns, | ||
| timezone, | ||
| }, | ||
| }, | ||
| }], |
There was a problem hiding this comment.
@Beamanator should this optimistic data actually update it in the UI automatically? Is it that we do not rerender the RHS when we go back from the settings?
Clicking back to the settings, still old name

I think that should be fixed because as user I would be perplexed what is correct.
|
@mountiny I also saw that prop type timezone error (you mentioned here) but not for the account I was testing with - I think it's a bug in how we default a timezone when that account doesn't have a timezone set in an NVP - but I'm not 100% sure, didn't have enough time to investigate today about why personal details aren't updating even after going away from the page & back, that's really weird I will test that out tomorrow 🤔 thanks for the thorough testing! |
|
No, thank you for working on this! |
|
Ok @vitHoracek it looks like this is the fix you're looking for, right? I'm about to commit these changes Screen.Recording.2022-07-29.at.1.06.42.PM.mov |
|
@Beamanator YAAASS 😍 |
| displayName: getDisplayName(currentUserEmail, { | ||
| firstName, | ||
| lastName, | ||
| }), |
There was a problem hiding this comment.
FYI this will need to be added in Web-E so that all clients get updated with this displayName, I plan to add this requirement in this issue: https://github.com/Expensify/Expensify/issues/220321
There was a problem hiding this comment.
Ok, but we should not get any problems when sending this. It will get updated for other users when their refresh, but it is not included in the Pusher update you saying?
There was a problem hiding this comment.
Right right exactly @mountiny - nothing will break, only the client making the change will get these updates automatically, others will get it after refresh 👍
|
Great!! This will not update on all clients yet (see my previous comment) but I'll fix that in a following Web-E PR 👍 |
|
Actually before we merge this, I'm going to add |
|
Ok now I think we're good to go again |
mountiny
left a comment
There was a problem hiding this comment.
I have one more outstanding question there.
Otherwise I think we are good to go with how the timezones work now, but we should update the test steps. Also I would copy them over from the Web-E so it is easier for QA to follow!
Great job Alex, this one is now easy
| const oldTimezoneData = myPersonalDetails.timezone || {}; | ||
| const newTimezoneData = { | ||
| automatic: lodashGet(oldTimezoneData, 'automatic', true), | ||
| selected: moment.tz.guess(true), |
There was a problem hiding this comment.
Discussed with Alex in DM, I think this function does not work as expected with the VPNs and it does not set you to the timezone of the area. However, that is how we have it now and I would argue it is better as in the chat you want others to see your actual timezone and not the VPN timezone.
| hasSelfSelectedPronouns: !_.isEmpty(this.props.currentUserPersonalDetails.pronouns) && !this.props.currentUserPersonalDetails.pronouns.startsWith(CONST.PRONOUNS.PREFIX), | ||
| selectedTimezone: lodashGet(this.props.currentUserPersonalDetails, 'timezone.selected', CONST.DEFAULT_TIME_ZONE.selected), | ||
| isAutomaticTimezone: lodashGet(this.props.currentUserPersonalDetails, 'timezone.automatic', CONST.DEFAULT_TIME_ZONE.automatic), | ||
| hasSelfSelectedPronouns: !(currentUserDetails.pronouns || '').startsWith(CONST.PRONOUNS.PREFIX), |
There was a problem hiding this comment.
@Beamanator I think this change is not gonna result in the same boolean right?
if pronouns is empty, we will get false for hasSelfSelectedPronouns here:
!_.isEmpty(this.props.currentUserPersonalDetails.pronouns)
but if pronouns is empty with the new line, that would be startsWith(PREFIX) is false and negating the entire line will give true.
Nonetheless, even if it is correct, it is hard to understand 😄
There was a problem hiding this comment.
Dude good shout, this would probably cause weird behavior if pronouns is empty 🙃 👍
I can revert part of the refactor here, just keeping the currentPersonalDetails simplification
mountiny
left a comment
There was a problem hiding this comment.
Thanks for working on thins and for all the changes!
|
Added necessary check back (for has personal pronouns), brought tests here from the Web-E PR, and changed the timezone checks to not test by using a VM |
|
Since Alberto approved the changes before, let's |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| PersonalDetails.updateProfile( | ||
| this.state.firstName.trim(), | ||
| this.state.lastName.trim(), | ||
| this.state.pronouns.trim(), | ||
| { | ||
| automatic: this.state.isAutomaticTimezone, | ||
| selected: this.state.selectedTimezone, | ||
| }, | ||
| }, true); | ||
| ); |
There was a problem hiding this comment.
This tiny change gave rise to #10215
Note: The main issue is opacity being incorrect, not the Growl being missing
|
🚀 Deployed to production by @yuwenmemon in version: 1.1.87-9 🚀
|

Details
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/211813
Tests
Same tests as: https://github.com/Expensify/Web-Expensify/pull/34219:
UpdateProfileOpenProfile[info] [Report] Handled onyxApiUpdate event sent by Pusher - [{"onyxMethod":"merge","key":"personalDetails","value":{"alexbeaman@expensifail.com":{"timezone":{"automatic":true,"selected":"Africa/Cairo"}}}}]DeleteUserAvatar[info] [Report] Handled onyxApiUpdate event sent by Pusher - [{"onyxMethod":"merge","key":"personalDetails","value":{"alexbeaman@expensifail.com":{"avatar":"https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_7.png"}}}]PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followed/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Same as "Tests" section, but don't worry about checking the logs
Screenshots
Web & Desktop
Updating timezone by opening profile:
Screen.Recording.2022-07-19.at.4.38.22.PM.mov
Deleting profile image:
Screen.Recording.2022-07-19.at.4.40.31.PM.mov
Updating profile info
Screen.Recording.2022-07-19.at.4.42.18.PM.mov
Mobile Web
iOS
Android