-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Cleanup Pusher subscriptions when signing out in another tab #5555
Conversation
I'll review this after lunch! |
@@ -249,7 +250,7 @@ class AuthScreens extends React.Component { | |||
if (this.unsubscribeGroupShortcut) { | |||
this.unsubscribeGroupShortcut(); | |||
} | |||
NetworkConnection.stopListeningForReconnect(); | |||
cleanupSession(); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
componentDidMount() { | |
NetworkConnection.listenForReconnect(); | |
PusherConnectionManager.init(); |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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
authToken
gets 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:AuthScreens
component which will unmount whenever theauthToken
is 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