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();
|
this._connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reconnect() {
|
||||||
|
this._connect();
|
||||||
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if (this.reconnectTimer != null) {
|
if (this.reconnectTimer != null) {
|
||||||
clearTimeout(this.reconnectTimer);
|
clearTimeout(this.reconnectTimer);
|
||||||
|
@ -38,8 +38,16 @@ export default class AppState extends TypedEventEmitter<AppEvents> {
|
|||||||
when(() => !this.tokenStore.accessToken.isValid, this.checkToken);
|
when(() => !this.tokenStore.accessToken.isValid, this.checkToken);
|
||||||
this.sprinklersRpc.start();
|
this.sprinklersRpc.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", this.onPageFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageFocus = () => {
|
||||||
|
if (document.visibilityState === "visible") {
|
||||||
|
this.sprinklersRpc.reconnect();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
get isLoggedIn() {
|
get isLoggedIn() {
|
||||||
return this.tokenStore.accessToken.isValid;
|
return this.tokenStore.accessToken.isValid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user