Skip to content

Commit 5019162

Browse files
author
Jeremy Ewing
committed
dashboard: fix WebSocket payload shape for live updates
The server sends {type:'snapshot', data: snapshot}, but the frontend was passing the whole envelope to renderMain(), so timestamp/registers were undefined and fields appeared blank. Use msg.data when available.
1 parent b4a2797 commit 5019162

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎api/static/index.html‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,13 @@ <h3>Global Control</h3>
859859
function connectWS() {
860860
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
861861
ws = new WebSocket(proto + '//' + location.host + '/ws');
862-
ws.onmessage = ev => { try { renderMain(JSON.parse(ev.data)); } catch(e){} };
862+
ws.onmessage = ev => {
863+
try {
864+
const msg = JSON.parse(ev.data);
865+
const payload = msg.type === 'snapshot' ? msg.data : msg;
866+
if (payload && payload.registers) renderMain(payload);
867+
} catch(e){}
868+
};
863869
ws.onclose = () => setTimeout(connectWS, 3000);
864870
}
865871

0 commit comments

Comments
 (0)