defer connection failed message (#13)

This commit is contained in:
mloginov 2024-07-03 10:48:31 +01:00 committed by GitHub
parent 1350d23ddd
commit 9f8811510f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 1 deletions

View File

@ -41,6 +41,7 @@ const UI = {
inhibitReconnect: true, inhibitReconnect: true,
reconnectCallback: null, reconnectCallback: null,
reconnectPassword: null, reconnectPassword: null,
disconnectStatusTimeout: null,
prime() { prime() {
return WebUtil.initSettings().then(() => { return WebUtil.initSettings().then(() => {
@ -1135,6 +1136,8 @@ const UI = {
}, },
reconnect() { reconnect() {
UI.disconnectStatusTimeout !== null && clearTimeout(UI.disconnectStatusTimeout);
UI.disconnectStatusTimeout = null;
UI.reconnectCallback = null; UI.reconnectCallback = null;
// if reconnect has been disabled in the meantime, do nothing. // if reconnect has been disabled in the meantime, do nothing.
@ -1191,7 +1194,11 @@ const UI = {
UI.showStatus(_("Something went wrong, connection is closed"), UI.showStatus(_("Something went wrong, connection is closed"),
'error'); 'error');
} else { } 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 // If reconnecting is allowed process it now