Re-auth on visibility change
This commit is contained in:
parent
d675342908
commit
89562b11b0
@ -92,6 +92,10 @@ export class WebSocketRpcClient extends s.SprinklersRPC {
|
||||
this._connect();
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
this._connect();
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.reconnectTimer != null) {
|
||||
clearTimeout(this.reconnectTimer);
|
||||
|
@ -38,8 +38,16 @@ export default class AppState extends TypedEventEmitter<AppEvents> {
|
||||
when(() => !this.tokenStore.accessToken.isValid, this.checkToken);
|
||||
this.sprinklersRpc.start();
|
||||
});
|
||||
|
||||
document.addEventListener("visibilitychange", this.onPageFocus);
|
||||
}
|
||||
|
||||
onPageFocus = () => {
|
||||
if (document.visibilityState === "visible") {
|
||||
this.sprinklersRpc.reconnect();
|
||||
}
|
||||
};
|
||||
|
||||
@computed
|
||||
get isLoggedIn() {
|
||||
return this.tokenStore.accessToken.isValid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user