Propagate incognito status change to server

This commit is contained in:
Pierre HUBERT 2020-04-01 10:51:07 +02:00
parent 321a91910f
commit 7f0d723e69

View File

@ -72,6 +72,14 @@ class UserWebSocket {
});
}
/**
* Get current connection status with the server
*/
static get IsConnected() {
return this.hasOwnProperty("ws")
&& this.ws.readyState == WebSocket.OPEN;
}
/**
* Handles websocket errors
*/
@ -211,3 +219,10 @@ class UserWebSocket {
queue.res(msg.data);
}
}
// Register some events
document.addEventListener("incognitoStatusChanged", (e) => {
if(UserWebSocket.IsConnected)
ws("$main/set_incognito", {enable: e.detail.enabled})
})