diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index 8fd5a056..0cb78fd4 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -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 */ @@ -210,4 +218,11 @@ class UserWebSocket { // It is a success queue.res(msg.data); } -} \ No newline at end of file +} + + +// Register some events +document.addEventListener("incognitoStatusChanged", (e) => { + if(UserWebSocket.IsConnected) + ws("$main/set_incognito", {enable: e.detail.enabled}) +}) \ No newline at end of file