Call listenForReconnect on App init#10314
Conversation
| } | ||
|
|
||
| // When the app reconnects from being offline, fetch all initialization data | ||
| NetworkConnection.listenForReconnect(); |
There was a problem hiding this comment.
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
subscribeToNetInfoinExpensify.js. Now we subscribe both our public and auth screens to NetInfo. - Remove
subscribeToNetInfofromlistenForReconnecthere - Move this call to onReconnect to AuthScreens'
componentDidMountmethod
Thoughts?
There was a problem hiding this comment.
Thanks! That's a great insight. I can give that a try and see how it works.
…listeners sit behind AuthScreens
|
Updated and retested! |
aldo-expensify
left a comment
There was a problem hiding this comment.
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.
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
c5fff92 to
757ff0c
Compare
|
Great catch @aldo-expensify! Updated! |
luacmartins
left a comment
There was a problem hiding this comment.
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
listenForReconnectallows us to do that.Fixed Issues
$ #10219
Tests/QA
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
The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarhave been tested & I retested again)/** 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)