-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Call listenForReconnect on App init #10314
Conversation
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.
Works like a charm 👍
src/libs/actions/App.js
Outdated
@@ -252,6 +252,7 @@ function openProfile() { | |||
} | |||
|
|||
// When the app reconnects from being offline, fetch all initialization data | |||
NetworkConnection.listenForReconnect(); |
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.
Hmm I'm not sure that we should be calling listenForReconnect
here, nor onReconnect
for that matter (my bad 😅 ). The reason being that it also registers our reconnect callbacks even when the user is not logged in! You can see calls to ReconnectApp
being triggered when you are logged out and come back online, which will inevitably fail with a session expired error.
I think that we should clean this up by:
- Call
subscribeToNetInfo
inExpensify.js
. Now we subscribe both our public and auth screens to NetInfo. - Remove
subscribeToNetInfo
fromlistenForReconnect
here - Move this call to onReconnect to AuthScreens'
componentDidMount
method
Thoughts?
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.
Thanks! That's a great insight. I can give that a try and see how it works.
…listeners sit behind AuthScreens
Updated and retested! |
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.
I think the offline state is not being kept correctly, do this steps:
- try to login with account that doesn't exists
- make yourself offline (chrome dev tools - network tab)
- you will see the offline indicator 👍
- click "Back"
- The offline indicator is gone and the "Continue" button is enabled, even if you are still offline. Clicking "Continue" now will put you in an endless spinner.
Screen.Recording.2022-08-09.at.3.53.17.PM.mov
Ah good catch - it looks like we re clearing the |
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.
That fixed it ;)
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.
One more thing... when you are offline in the login form (Phone/email input), you can type and press enter submitting the form, even if there is no internet. This sends the requests, fails, and if you regain connection, you see the button spinning for ever. Steps:
- Go to the login form
- Disable connection
- Type an email and press enter
- See in the network tab the request being sent and failing
- Enable the connection
- The button has a permanent spinner
(this was already happening before your last change)
I guess you return early in the submit function if you detect we are offline?
App/src/pages/signin/LoginForm.js
Lines 116 to 121 in 75d70d9
validateAndSubmitForm() { | |
const login = this.state.login.trim(); | |
if (!login) { | |
this.setState({formError: 'common.pleaseEnterEmailOrPhoneNumber'}); | |
return; | |
} |
c5fff92
to
757ff0c
Compare
Great catch @aldo-expensify! Updated! |
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.
Left a couple of comments. There's still a bug similar to what @aldo-expensify described before:
- Enter your email
- Click
Forgot?
- Go offline
- Click back
- There's no offline indicator, the submit button is not disabled and submitting an email results in an endless spinner.
web.mov
@luacmartins are you sure you are on the most recent version of the branch? This is not happening for me: Kapture.2022-08-10.at.16.47.08.mp4 |
Lol I thought I had pulled the latest changes, but clearly not 🤣 Sorry about that! LGTM! The change from enabled -> disabled when we go back from Forgot to the LoginForm seems jarring but NAB IMO |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Pullerbearing (@aldo-expensify)
cc @luacmartins and @NikkiWines for a second set of eyes
Details
We are not Subscribing to NetInfo until we enter the AuthScreens, which means we don't track online/offline status until you sign in. Calling
listenForReconnect
allows us to do that.Fixed Issues
$ #10219
Tests/QA
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
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
have been tested & I retested again)/** 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)