From 4c5a6085315d2d4f44f83da1b631f2e351258e2b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 30 Mar 2020 14:24:45 +0200 Subject: [PATCH] Reload page only if WebSocket was not gracefully closed --- assets/js/common/ws.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/js/common/ws.js b/assets/js/common/ws.js index 92234bbd..3595d642 100644 --- a/assets/js/common/ws.js +++ b/assets/js/common/ws.js @@ -48,11 +48,17 @@ class UserWebSocket { static async Closed(e) { console.error("WS closed", e) + // Check if the server was gracefully stopped + if(!this.hasOwnProperty("ws")) + return; + const num_seconds = ComunicWeb.__config.productionMode ? 5 : 0.5; notify("Disconnected from the server, page will be reloaded in "+num_seconds+" seconds !", "danger"); - setTimeout(() => ComunicWeb.common.system.restart(), num_seconds*1000); + setTimeout(() => { + ComunicWeb.common.system.restart(); + }, num_seconds*1000); } /**