From 9f8811510f62de1b18fd708a1eba1b09bdda68ce Mon Sep 17 00:00:00 2001 From: mloginov Date: Wed, 3 Jul 2024 10:48:31 +0100 Subject: [PATCH] defer connection failed message (#13) --- app/ui.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index dfa11e17..91032c00 100644 --- a/app/ui.js +++ b/app/ui.js @@ -41,6 +41,7 @@ const UI = { inhibitReconnect: true, reconnectCallback: null, reconnectPassword: null, + disconnectStatusTimeout: null, prime() { return WebUtil.initSettings().then(() => { @@ -1135,6 +1136,8 @@ const UI = { }, reconnect() { + UI.disconnectStatusTimeout !== null && clearTimeout(UI.disconnectStatusTimeout); + UI.disconnectStatusTimeout = null; UI.reconnectCallback = null; // if reconnect has been disabled in the meantime, do nothing. @@ -1191,7 +1194,11 @@ const UI = { UI.showStatus(_("Something went wrong, connection is closed"), 'error'); } else { - UI.showStatus(_("Failed to connect to server"), 'error'); + UI.disconnectStatusTimeout !== null && clearTimeout(UI.disconnectStatusTimeout); + UI.disconnectStatusTimeout = setTimeout(() => { + UI.showStatus(_("Failed to connect to server"), 'error'); + UI.disconnectStatusTimeout = null; + }, 20 * 1000); } } // If reconnecting is allowed process it now