Cleanup Pusher subscriptions when signing out in another tab#5555
Conversation
|
I'll review this after lunch! |
| this.unsubscribeGroupShortcut(); | ||
| } | ||
| NetworkConnection.stopListeningForReconnect(); | ||
| cleanupSession(); |
There was a problem hiding this comment.
NAB: I was wondering why do we do this here instead of in clearStorageAndRedirect. I feels like the clean up logic is spread and it could be more centralized.
There was a problem hiding this comment.
Ah, mainly because we are setting up the subscriptions in AuthScreens componentDidMount() here:
App/src/libs/Navigation/AppNavigator/AuthScreens.js
Lines 157 to 159 in ccef3d9
so I thought it made more sense to tear them down in componentWillUnmount().
We definitely could do it in clearStorageAndRedirect() but I think making the "cleanup" stuff a side effect of losing the authToken is OK because we set up a lot of logic in componentDidMount() that could also be triggered by the presence of the authToken.
Basically the assumption is that AuthScreens mounted = we have authToken and AuthScreen unmount = we lost the authToken.
But yeah I wouldn't mind cleaning this up eventually or doing something differently if it becomes complicated enough to where people are thoroughly confused about how it works.
There was a problem hiding this comment.
Ah, mainly because we are setting up the subscriptions in AuthScreens componentDidMount() here:
Ohh that makes sense, I only looked at the code in componentWillUnmount
But yeah I wouldn't mind cleaning this up eventually or doing something differently if it becomes complicated enough to where people are thoroughly confused about how it works.
Agreed, I think it is good for now like it is, there is a good enough reason to keep it there.
aldo-expensify
left a comment
There was a problem hiding this comment.
Tested it in web, it works 🎉
Left a NAB.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by @aldo-expensify in version: 1.1.3-2 🚀
|
|
🚀 Deployed to production by @chiragsalian in version: 1.1.4-0 🚀
|
Details
When signing out in another tab we are not always unsubscribing from Pusher. This is because the
authTokengets removed, but none of the logic that runs inredirectToSignIn()runs on additional tabs. Additionally, the Onyx cache does not get cleared in other tabs although storage does (because it is shared). This PR solves these two issues by:AuthScreenscomponent which will unmount whenever theauthTokenis unsetOnyx.clear()on all tabs (for the session) and not just the one where we sign outFixed Issues
$ #5034
$ https://github.com/Expensify/Expensify/issues/177689
Tests / QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android