Enhance WebSocket handling and log polling logic
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-11 16:25:48 +11:00
parent ffd43d5217
commit e48a061ca0
6 changed files with 126 additions and 39 deletions

View File

@@ -997,10 +997,43 @@ function initShellLayout() {
setConnectionState("idle");
SHELL_LAYOUT_READY = true;
}
function shouldPollLogs() {
if (document.hidden == true) {
return false;
}
if (document.getElementById("content_log") == null) {
return false;
}
if (ACTIVE_MENU_ID.length < 1) {
return false;
}
var activeItem = document.getElementById(ACTIVE_MENU_ID);
if (activeItem == null) {
return false;
}
return activeItem.getAttribute("data-menu") == "log";
}
function PageReady() {
initShellLayout();
var server = new Server("getServerConfig");
server.request(new Object());
var bootstrapAttempts = 0;
var maxBootstrapAttempts = 5;
var bootstrapTimer = window.setInterval(function () {
if (SERVER.hasOwnProperty("clientInfo") == true) {
window.clearInterval(bootstrapTimer);
return;
}
if (SERVER_CONNECTION == true) {
return;
}
bootstrapAttempts++;
var retryServer = new Server("getServerConfig");
retryServer.request(new Object());
if (bootstrapAttempts >= maxBootstrapAttempts) {
window.clearInterval(bootstrapTimer);
}
}, 3000);
window.addEventListener("resize", function () {
if (window.innerWidth > 900) {
setLayoutMenuState(false);
@@ -1008,7 +1041,7 @@ function PageReady() {
calculateWrapperHeight();
}, true);
setInterval(function () {
if (document.hidden == true) {
if (shouldPollLogs() == false) {
return;
}
updateLog();

View File

@@ -27,6 +27,7 @@ var Server = /** @class */ (function () {
}
var url = this.protocol + wsHost + "/data/" + "?Token=" + getCookie("Token");
data["cmd"] = this.cmd;
var requestCmd = data["cmd"];
var ws = new WebSocket(url);
var isLogUpdate = data["cmd"] == "updateLog";
var responseReceived = false;
@@ -88,7 +89,7 @@ var Server = /** @class */ (function () {
errorState = "idle";
}
finishRequest(errorState, false);
if (WS_AVAILABLE == false && isLogUpdate == false) {
if (WS_AVAILABLE == false && isLogUpdate == false && requestCmd != "getServerConfig") {
alert("No websocket connection to xTeVe could be established. Check your network configuration.");
}
};