-
Notifications
You must be signed in to change notification settings - Fork 16
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
WIP feat: Terminates realtime on client logout #548
base: master
Are you sure you want to change the base?
Conversation
35ab7dd
to
c53f650
Compare
456019a
to
3a0d235
Compare
5877c87
to
a2fce7d
Compare
3a0d235
to
22e318c
Compare
a2fce7d
to
52b4ecf
Compare
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 that initialize the client and get logged in should be the responsability of the application and the bar should throw an error if it's initialize with a not logged in client, the bar can't work for now if the client is not usable anyway
9ceb2cb
to
9b1c4e7
Compare
9b1c4e7
to
e940330
Compare
52b4ecf
to
f9c4110
Compare
Attach on one-time handler to unsubscribe realtime handlers on client logout
f9c4110
to
83d7165
Compare
} | ||
if (cozyClient.isLogged) { | ||
onLogin() | ||
} |
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.
Tu ne tentes pas de réagir à l'événement de login s'il arrive plus tard ?
@ptbrowne Les issues dont du parles on clairement besoin d'être fixée. Mais vu qu'un gros boulot a été fait en parallèle sur le realtime et l'intégration dans la bar, est-ce qu'on a encore besoin de cette PR ? |
Tu parles de quoi en particulier ? |
Ca me dérange pas de rouvrir une issue "Faire de la bar un plugin cozy-client" :) |
De rien en fait, je pensais qu'on avait fait le travail pour AF après cette PR, mais en fait non, elle en découle. |
@ptbrowne est-ce que tu veux rebaser cette PR? |
I am leaving this open as it seems important that the bar closes its realtime sockets after logout, I have not checked if the behavior is still happening, cc @Crash-- |
The bar inits realtime and attaches handlers on initialization. The realtime does add a "logout" event handler that
unsubscribeAll()
but I think it is brittle to rely on this fact. When subscribing to something, the code should also clean behind itself. This way, if the realtime library decides to change (and not unsubscribe all events on client logout), the bar code would still work.To fix this problem, initializeRealtime now returns a function that serves to unsubscribe handlers. When the stack-client calls initializeRealtime, it also attaches a one-time handler to terminate the realtime on logout.
Another potential problem was that the bar, if initialized with a logged out client would never initialize the realtime. To mitigate this problem: if the bar is initialized with a logged out client, it attaches a one-time handler on the "login" event to initialize the realtime. I am still wondering if this is something that is possible (the bar being set up with a logged out client), see #548 (comment). At the moment, Banks inits the bar on client "login" but it puts the burden of instantiating the bar on the app. I think it could be simpler, and the bar could automatically connect/disconnect from the DOM on itself. It could be done in another commit, but I am curious about your thoughts.