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 <noreply@anthropic.com>
This commit is contained in:
parent
e304fd342d
commit
0b7f2401bd
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue