From 0b7f2401bd403614465fd7a83311e1337fa42a51 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 26 Mar 2026 09:37:00 +0800 Subject: [PATCH] feat(ws): refresh units and equipments on WebSocket reconnect After a disconnect/reconnect, re-fetch units (runtimes) and equipments (monitor data) so the UI reflects current server state without requiring a page reload. Co-Authored-By: Claude Sonnet 4.6 --- web/js/logs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/js/logs.js b/web/js/logs.js index 83ae7c9..1e7faf6 100644 --- a/web/js/logs.js +++ b/web/js/logs.js @@ -3,7 +3,8 @@ import { dom } from "./dom.js"; import { prependEvent } from "./events.js"; import { formatValue } from "./points.js"; import { state } from "./state.js"; -import { renderUnits } from "./units.js"; +import { loadUnits, renderUnits } from "./units.js"; +import { loadEquipments } from "./equipment.js"; import { showToast } from "./api.js"; function escapeHtml(text) { @@ -80,6 +81,7 @@ function setWsStatus(connected) { } let _reconnectDelay = 1000; +let _connectedOnce = false; export function startPointSocket() { const protocol = location.protocol === "https:" ? "wss" : "ws"; @@ -89,6 +91,11 @@ export function startPointSocket() { ws.onopen = () => { setWsStatus(true); _reconnectDelay = 1000; + if (_connectedOnce) { + loadUnits().catch(() => {}); + loadEquipments().catch(() => {}); + } + _connectedOnce = true; }; ws.onmessage = (event) => {