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 dashboardWs = null;
|
||||||
let dashboardWsConnected = false;
|
let dashboardWsConnected = false;
|
||||||
let wsReconnectTimer = null;
|
let wsReconnectTimer = null;
|
||||||
|
const manuallyDisconnecting = new Set();
|
||||||
|
|
||||||
function moveClientCardImmediately(msg) {
|
function moveClientCardImmediately(msg) {
|
||||||
const clientId = typeof msg?.clientId === "string" ? msg.clientId : "";
|
const clientId = typeof msg?.clientId === "string" ? msg.clientId : "";
|
||||||
@@ -157,8 +158,13 @@ function connectDashboardWs() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg && msg.type === "client_event") {
|
if (msg && msg.type === "client_event") {
|
||||||
moveClientCardImmediately(msg);
|
if (msg.event === "client_offline" && manuallyDisconnecting.has(msg.clientId)) {
|
||||||
loadWithOptions({ force: false, reorder: true });
|
manuallyDisconnecting.delete(msg.clientId);
|
||||||
|
loadWithOptions({ force: true });
|
||||||
|
} else {
|
||||||
|
moveClientCardImmediately(msg);
|
||||||
|
loadWithOptions({ force: false, reorder: true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
};
|
};
|
||||||
@@ -205,6 +211,11 @@ export function startAutoRefresh(intervalMs = POLL_INTERVAL_MS) {
|
|||||||
}, effectiveInterval);
|
}, effectiveInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function markManualDisconnect(clientId) {
|
||||||
|
manuallyDisconnecting.add(clientId);
|
||||||
|
setTimeout(() => manuallyDisconnecting.delete(clientId), 10000);
|
||||||
|
}
|
||||||
|
|
||||||
export async function sendCommand(clientId, action) {
|
export async function sendCommand(clientId, action) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/clients/${clientId}/command`, {
|
const res = await fetch(`/api/clients/${clientId}/command`, {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
sendCommand,
|
sendCommand,
|
||||||
requestPreview,
|
requestPreview,
|
||||||
requestThumbnail,
|
requestThumbnail,
|
||||||
|
markManualDisconnect,
|
||||||
} from "./data.js";
|
} from "./data.js";
|
||||||
import { initCountryPicker } from "./country-picker.js";
|
import { initCountryPicker } from "./country-picker.js";
|
||||||
|
|
||||||
@@ -620,6 +621,7 @@ bulkDisconnectBtn?.addEventListener("click", async () => {
|
|||||||
|
|
||||||
let success = 0;
|
let success = 0;
|
||||||
for (const clientId of selectedClients) {
|
for (const clientId of selectedClients) {
|
||||||
|
markManualDisconnect(clientId);
|
||||||
const ok = await sendCommand(clientId, "disconnect");
|
const ok = await sendCommand(clientId, "disconnect");
|
||||||
if (ok) success++;
|
if (ok) success++;
|
||||||
}
|
}
|
||||||
@@ -976,6 +978,10 @@ menu.addEventListener("click", async (e) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action === "disconnect") {
|
||||||
|
markManualDisconnect(contextCard);
|
||||||
|
}
|
||||||
|
|
||||||
const ok = await sendCommand(contextCard, action);
|
const ok = await sendCommand(contextCard, action);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
setTimeout(() => loadWithOptions({ force: true }), 400);
|
setTimeout(() => loadWithOptions({ force: true }), 400);
|
||||||
|
|||||||
Reference in New Issue
Block a user