don't play animation if you disconnect a single client

This commit is contained in:
KingKDot
2026-04-13 20:02:58 -05:00
parent c995d17245
commit 41f8f087ce
2 changed files with 19 additions and 2 deletions
+13 -2
View File
@@ -9,6 +9,7 @@ let render = () => {};
let dashboardWs = null;
let dashboardWsConnected = false;
let wsReconnectTimer = null;
const manuallyDisconnecting = new Set();
function moveClientCardImmediately(msg) {
const clientId = typeof msg?.clientId === "string" ? msg.clientId : "";
@@ -157,8 +158,13 @@ function connectDashboardWs() {
return;
}
if (msg && msg.type === "client_event") {
moveClientCardImmediately(msg);
loadWithOptions({ force: false, reorder: true });
if (msg.event === "client_offline" && manuallyDisconnecting.has(msg.clientId)) {
manuallyDisconnecting.delete(msg.clientId);
loadWithOptions({ force: true });
} else {
moveClientCardImmediately(msg);
loadWithOptions({ force: false, reorder: true });
}
}
} catch {}
};
@@ -205,6 +211,11 @@ export function startAutoRefresh(intervalMs = POLL_INTERVAL_MS) {
}, effectiveInterval);
}
export function markManualDisconnect(clientId) {
manuallyDisconnecting.add(clientId);
setTimeout(() => manuallyDisconnecting.delete(clientId), 10000);
}
export async function sendCommand(clientId, action) {
try {
const res = await fetch(`/api/clients/${clientId}/command`, {