-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Stop using MY_PERSONAL_DETAILS and only use PERSONAL_DETAILS in Onyx #9560
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
Conversation
…_PERSONAL_DETAILS
…Y_PERSONAL_DETAILS
…_PERSONAL_DETAILS
…_PERSONAL_DETAILS
marcaaron
left a comment
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.
Happy we are getting rid of this 👍 🙇♂️
Had a few initial comments not a full review.
Beamanator
left a comment
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.
Another interesting thing I've noticed: A few components directly subscribe to ONYXKEYS.PERSONAL_DETAILS via withOnyx, but some use withPersonalDetails.
Do you think we could standardize this as well?
| import ROUTES from '../ROUTES'; | ||
| import networkPropTypes from './networkPropTypes'; | ||
| import {withNetwork} from './OnyxProvider'; | ||
| import personalDetailsPropType from '../pages/personalDetailsPropType'; |
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.
NAB - should be plural since there's more than one prop type in this file - though this isn't your fault since you didn't create the original file :D
| import personalDetailsPropType from '../pages/personalDetailsPropType'; | |
| import personalDetailsPropTypes from '../pages/personalDetailsPropTypes'; |
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.
Good call. Updating.
src/pages/RequestCallPage.js
Outdated
|
|
||
| /** The personal details of the person who is logged in */ | ||
| myPersonalDetails: personalDetailsPropType.isRequired, | ||
| /** Personal details of all the users */ |
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.
In AdditionalDetailsStep.js you have this at the end of the same comment: , including current user
Probably should be consistent - I think it makes sense to keep , including current user in these comments
|
Ok, everything is updated! To recap:
Please give it another review 🙏🏾 |
marcaaron
left a comment
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.
LGTM 👍
| return; | ||
| } | ||
|
|
||
| const timezone = lodashGet(val, currentUserEmail, 'timezone', {}); |
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.
NAB, it seems like there is a very remote chance that currentUserEmail won't have a value at this point. It depends entirely on the session.email data being set before the personalDetails and both would be set when the user logs in actually not 100% sure when they would be set.
The subscriptions here feel out of place though and should be probably be moved into PersonalDetails (but not necessary to do that now).
|
Gonna merge this so we can unblock some other open PRs. Tested and code is 👍 |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
| return; | ||
| } | ||
|
|
||
| const timezone = lodashGet(val, currentUserEmail, 'timezone', {}); |
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.
Looks like this needed to be lodashGet(val, [currentUserEmail, 'timezone'], {});
| key: ONYXKEYS.PERSONAL_DETAILS, | ||
| callback: (val) => { | ||
| timezone = lodashGet(val, 'timezone', CONST.DEFAULT_TIME_ZONE); | ||
| timezone = lodashGet(val, currentUserEmail, 'timezone', CONST.DEFAULT_TIME_ZONE); |
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.
Same with this one :)
| selectedTimezone: lodashGet(this.props.currentUserPersonalDetails.timezone, 'selected', CONST.DEFAULT_TIME_ZONE.selected), | ||
| isAutomaticTimezone: lodashGet(this.props.currentUserPersonalDetails.timezone, 'automatic', CONST.DEFAULT_TIME_ZONE.automatic), |
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.
Here maybe we can put the timezone prop with selected & automatic
|
Fixing ^ issues in #10043 |
|
🚀 Deployed to production by @luacmartins in version: 1.1.85-8 🚀
|
|
Thanks for catching those @Beamanator! |
|
I am tagging this PR to highlight an issue fixed here. All conditions in ternary expressions or left-hand operands on conditional renders, should be boolean. This PR is one of the PRs that uses conditional render with string operands, hence I am tagging it here for the contributors to check. We've also updated the item in the checklist with this PR to avoid this issue in the future. |
|
Thanks for pointing that out! |
Details
Today, we have two different Onyx keys that store the same information.
MY_PERSONAL_DETAILSwhich stores only the personal details of the logged in user. AndPERSONAL_DETAILSwhich stores the personal details of the logged in user and other users they interact with in the app.This PR makes it so that we are no longer storing duplicate data by getting rid of the
MY_PERSONAL_DETAILSkey. Any component that needs the personal details of the current user instead gets the information from thePERSONAL_DETAILSkey. In addition, I've added{isCurrentUser: true}to the personal details object for the current logged in user in order to make it easy to find/reference.Fixed Issues
https://github.com/Expensify/Expensify/issues/215037
Tests
MY_PERSONAL_DETAILSkey exists.PERSONAL_DETAILSkey in Onyx has details for the logged in user{isCurrentUser: true}as part of the object.timezoneas part of the object and that it updates successfully in Onyx when changed in personal settingslocalCurrencyas part of the object.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
Screenshots
Web
Mobile Web
Desktop
iOS
Android