This commit is contained in:
Ankit Kumar 2026-05-23 19:17:34 +02:00 committed by GitHub
commit 45438d80cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,7 @@ const UI = {
inhibitReconnect: true, inhibitReconnect: true,
reconnectCallback: null, reconnectCallback: null,
reconnectPassword: null, reconnectPassword: null,
firstReconnectTime: null,
wakeLockManager: new WakeLockManager(), wakeLockManager: new WakeLockManager(),
@ -965,6 +966,9 @@ const UI = {
UI.closePowerPanel(); UI.closePowerPanel();
} }
}, },
resetFirstReconnection() {
UI.firstReconnectTime = null;
},
/* ------^------- /* ------^-------
* /POWER * /POWER
@ -1129,6 +1133,23 @@ const UI = {
reconnect() { reconnect() {
UI.reconnectCallback = null; UI.reconnectCallback = null;
const MAX_RECONNECT_TIME_SECONDS = 10 * 60; // 10 * 60s
const MAX_TIME_IN_MS = MAX_RECONNECT_TIME_SECONDS * 1000;
// Initialize first reconnect time if it's the first attempt
if (UI.firstReconnectTime === null) {
UI.firstReconnectTime = Date.now();
}
// Check if we've exceeded the max reconnect time
if ((Date.now() - UI.firstReconnectTime) >= MAX_TIME_IN_MS) {
// hiding the previous status message
UI.hideStatus();
// Showing this message for long time, because if the connection is unstable and user is not around to see the message when the connection is lost, they will be able to see it when they will come back. (Showing for 3 hours)
UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 180 * 60 * 1000);
UI.updateVisualState('disconnected');
return;
}
// if reconnect has been disabled in the meantime, do nothing. // if reconnect has been disabled in the meantime, do nothing.
if (UI.inhibitReconnect) { if (UI.inhibitReconnect) {
@ -1162,6 +1183,7 @@ const UI = {
} }
UI.showStatus(msg); UI.showStatus(msg);
UI.updateVisualState('connected'); UI.updateVisualState('connected');
UI.resetFirstReconnection();
UI.updateBeforeUnload(); UI.updateBeforeUnload();