-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Prevent "Continue setup" navigating back immediately #8498
Conversation
Prevent multiple updates to the session and store the accountID as int
Bumping @TomatoToaster |
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.
Oh my b, I thought I already gave this an approve, LGTM!
@neil-marcellini are we going to have [No QA] for this? I wasn't sure if you wanted to test the part after |
@TomatoToaster since this PR only merges into the feature branch |
@@ -111,6 +129,9 @@ LogInWithShortLivedTokenPage.propTypes = propTypes; | |||
LogInWithShortLivedTokenPage.defaultProps = defaultProps; | |||
|
|||
export default withOnyx({ | |||
betas: { | |||
key: ONYXKEYS.BETAS, | |||
}, |
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.
Oh the betas are back now? 😂
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.
😅 yes unfortunately
|
||
navigateToExitRoute() { | ||
if (!this.props.betas) { | ||
// Wait to navigate until the betas are loaded. Some pages like ReimbursementAccountPage require betas, so keep loading until they are available. |
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.
thought: This would be easier to understand if we do not use componentDidUpdate()
to mean "wait to navigate until the betas are loaded". It's not clear what specifically we are "waiting" for or where it happens. Who calls getBetas()
and why are we waiting for that to happen here?
suggestion: The comment about ReimbursementAccountPage
creates a non-code dependency that should be changed as it's impossible to keep up to date. If ReimbursementAccountPage
some day has no need for the betas will anyone remember to update this 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.
You are right that this is very fragile and doesn't make much sense.
What do we do if someone who isn't on the betas required for the ReimbursementAccountPage tries to navigate there? Currently we kick them back to the home page immediately, but that is problematic if they will have access to that page once the betas load. We could instead show a loading screen on the ReimbursementAccountPage until the betas have loaded. Is that a good solution?
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.
Gonna think about this for a bit.
|
||
componentDidUpdate() { | ||
this.navigateToExitRoute(); | ||
} |
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.
Other things could later update this component... should we "navigate to the exit route" if they do?
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 only things that can make this component update are the props correct? So as long as we don't add more props / Onyx keys it will be fine.
What if we moved all of this into an action called "signInTransitioningUser" that would handle signing in, out, and navigating? That way instead of using componentDidUpdate to wait for changes we could use promises / Onyx callbacks to call these actions in sequence. For example, sign out old user > wait for onyx to clear > sign in new user > navigate. I'm not sure if that's any different than what we are doing here, but please let me know what you 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.
The only things that can make this component update are the props correct
componentDidUpdate()
runs after a component's render()
method is called. a change in props or state will cause the component to render, but so can other things like a parent component re-rendering (with no change at all to props or state).
So as long as we don't add more props / Onyx keys it will be fine.
That's a good way to rephrase my concern 😄
How do we make everyone understand that the possibility exists to add more props and for things to not be fine?
What if we moved all of this into an action called "signInTransitioningUser" that would handle signing in, out, and navigating? That way instead of using componentDidUpdate to wait for changes we could use promises / Onyx callbacks to call these actions in sequence. For example, sign out old user > wait for onyx to clear > sign in new user > navigate. I'm not sure if that's any different than what we are doing here, but please let me know what you think.
This sounds interesting and I think it is pretty different compared to what we are doing here. It also sounds much easier to follow because the code paths will be separated cleanly and we won't have to worry about which "case" we are handling as we bounce between different lifecycle methods. Let's chat more 1:1 about this.
Thanks for the comments @marcaaron. Sorry that I forgot to wait before merging. |
🚀 Deployed to staging by @neil-marcellini in version: 1.1.72-0 🚀
|
🚀 Deployed to production by @yuwenmemon in version: 1.1.73-2 🚀
|
Details
Prevent immediately navigating back to OldDot when signed out and following the "Continue setup" transition flow.
Related Issue
$ #8295
Tests
First, set up your dev environment so that the betas load slowly.
$allBetasEnabled
to false here[BetaManager::BETA_FREE_PLAN, BetaManager::BETA_FREE_PLAN_FULL_LAUNCH];
to the Web-Expensify BetaManager hereNow test:
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followed/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)QA Steps
Screenshots
Web
Mobile Web
Desktop
iOS
Android