don't play animation if you disconnect a single client
This commit is contained in:
@@ -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`, {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
sendCommand,
|
||||
requestPreview,
|
||||
requestThumbnail,
|
||||
markManualDisconnect,
|
||||
} from "./data.js";
|
||||
import { initCountryPicker } from "./country-picker.js";
|
||||
|
||||
@@ -620,6 +621,7 @@ bulkDisconnectBtn?.addEventListener("click", async () => {
|
||||
|
||||
let success = 0;
|
||||
for (const clientId of selectedClients) {
|
||||
markManualDisconnect(clientId);
|
||||
const ok = await sendCommand(clientId, "disconnect");
|
||||
if (ok) success++;
|
||||
}
|
||||
@@ -976,6 +978,10 @@ menu.addEventListener("click", async (e) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === "disconnect") {
|
||||
markManualDisconnect(contextCard);
|
||||
}
|
||||
|
||||
const ok = await sendCommand(contextCard, action);
|
||||
if (ok) {
|
||||
setTimeout(() => loadWithOptions({ force: true }), 400);
|
||||
|
||||
Reference in New Issue
Block a user