Skip to content
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 navigating to workspace by preloading betas #5443

Merged
merged 6 commits into from
Sep 23, 2021

Conversation

iwiznia
Copy link
Contributor

@iwiznia iwiznia commented Sep 23, 2021

Details

Fixed Issues

Issue uncovered while testing #5439 in stg

Tests

  • Ignore for QA: remove isDevelopment() || from here
    return isDevelopment() || _.contains(betas, CONST.BETAS.ALL);
  • Make sure you are signed out of newDot
  • Create a new account on oldDot
  • Go to Settings > Policies > Group
  • Create a free policy
  • Check newDot opens and shows the workflow page
  • Create another free policy
  • Check newDot opens and shows the workflow page
  • Sign out of newDot
  • Refresh oldDot
  • Click on one of the free policies
  • Check newDot opens and shows the workflow page
  • Click on one of the free policies
  • Check newDot opens and shows the workflow page

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

image

@iwiznia iwiznia requested a review from Julesssss September 23, 2021 10:50
@iwiznia iwiznia requested a review from a team as a code owner September 23, 2021 10:50
@iwiznia iwiznia self-assigned this Sep 23, 2021
@iwiznia iwiznia removed the request for review from a team September 23, 2021 10:50
@MelvinBot MelvinBot requested a review from HorusGoul September 23, 2021 10:51
@iwiznia iwiznia removed the request for review from HorusGoul September 23, 2021 10:51
@github-actions
Copy link
Contributor

⚠️ ⚠️ Heads up! This pull request has the CP Staging label. ⚠️ ⚠️
Merging it will cause it to be immediately deployed to staging, even if the open StagingDeployCash deploy checklist is locked.

Comment on lines 60 to 64
/**
* @return {Promise}
*/
function getBetas() {
API.User_GetBetas().then((response) => {
return API.User_GetBetas().then((response) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning from an Action function (that is consumed OUTSIDE of the Action file) breaks our architecture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh fuck, you are right!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pain, but I see two alternatives:

  1. Pass a flag to getBetas(shouldCloseModal) and then close the modals within the action
  2. Add an Onyx key, subscribe in LogInWithShortLivedTokenPage

@iwiznia
Copy link
Contributor Author

iwiznia commented Sep 23, 2021

Updated and retested

class LogInWithShortLivedTokenPage extends Component {
constructor(props) {
super(props);
this.state = {run: false};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really get run for the state variable, should it be hasRan?

Copy link
Contributor Author

@iwiznia iwiznia Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hasRun would be a better name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested the latest changes yet, but this seems much more complicated than simply adding a new Action function:

function getBetasAndCloseModal() {
    getBetas().then(() => {
         Navigation.dismissModal();
         Navigation.navigate(exitTo);
    };
}

This is pretty bad, but at least it is simple.

@iwiznia
Copy link
Contributor Author

iwiznia commented Sep 23, 2021

I haven't tested the latest changes yet, but this seems much more complicated than simply adding a new Action function:

IMO that's just a hack. Getting betas has nothing to do with modals or navigating to another page. I even prefer the previous solution to that.
Anyway, I think this is ok, let me know if it makes sense with the clarification I added in the comment above.

// and by calling dismissModal(), the /transition/... route is removed from history so the user will get taken to `/`
// if they cancel out of the new workspace modal.
Navigation.dismissModal();
Navigation.navigate(exitTo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final comment, do we need to call this.setState({run: true}) here too, to prevent other GetBeta API calls from triggering Navigation.navigate a second time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the GetBetas API call is now happening twice

Copy link
Contributor Author

@iwiznia iwiznia Sep 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the GetBetas API call is now happening twice

Fixed that

Final comment, do we need to call this.setState({run: true}) here too, to prevent other GetBeta API calls from triggering Navigation.navigate a second time?

We can't since you should not call setState from componentDidUpdate according to linter. In any case it is not needed since once we navigate this component stops existing.

@Julesssss
Copy link
Contributor

Julesssss commented Sep 23, 2021

I'm seeing Your session has expired. Please sign in again. consistently now (note that this was after I commented out the User.GetBetas line as we discussed)

TestingPolicyRedirect.mov

Clearing session on new.dot resolved the issue though.

@iwiznia
Copy link
Contributor Author

iwiznia commented Sep 23, 2021

ok, updated one more time and retested it. The call to getBetas was not really needed as that is loaded once we are signed in (either because we already were or after we create the login).

Julesssss
Julesssss previously approved these changes Sep 23, 2021
@iwiznia iwiznia merged commit 874f694 into main Sep 23, 2021
@iwiznia iwiznia deleted the ionatan_fix_linking_betas branch September 23, 2021 15:17
@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by @iwiznia in version: 1.1.1-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes.

@isagoico
Copy link

@iwiznia I'm getting a blank screen and a JS error after creating a Free Plan policy on this step Check newDot opens and shows the workflow page
image

@iwiznia
Copy link
Contributor Author

iwiznia commented Sep 23, 2021

That's odd, I just tested it all and worked. Maybe it's related to the account? Can you share the credentials to access it?

@isagoico
Copy link

isagoico commented Sep 23, 2021

So weird I just tried now and it worked 🤯
image

Tested all the steps and they were a pass 🎉 I'm double checking with the team

@isagoico
Copy link

Checking it off since it was a pass 🎉

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @Jag96 in version: 1.1.1-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @iwiznia in version: 1.1.1-9 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @timszot in version: 1.1.2-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants