From 098cc1c66f654b3b3cff77677083d22a3d258171 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Sat, 5 Sep 2026 19:08:10 +0200 Subject: [PATCH] fix(player): order refreshDevices like the WebSocket frames The `devices` and `status_update` frames are now applied by revision, but refreshDevices() still replaced the whole map with whatever the REST call returned. A refresh issued before a socket update but answered after it would put the older status back. Route it through mergeDevicesSnapshot as well. Entries the snapshot omits are still dropped, so device removal keeps working, and info/stereoPair still come from the snapshot even when its status loses the comparison. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/service/soundtouchweb/static/js/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/service/soundtouchweb/static/js/app.js b/pkg/service/soundtouchweb/static/js/app.js index e0d4f9cc..2ec09881 100644 --- a/pkg/service/soundtouchweb/static/js/app.js +++ b/pkg/service/soundtouchweb/static/js/app.js @@ -246,7 +246,9 @@ function App() { async function refreshDevices() { const resp = await api.devices(); if (!resp?.success) throw new Error(resp?.error || 'Failed to refresh devices'); - setDevices(resp.data || {}); + // Ordered like the WebSocket frames: a slow REST snapshot must not + // clobber a newer status that arrived over the socket meanwhile. + setDevices(previous => mergeDevicesSnapshot(previous, resp.data)); } function mergeDeviceReadback(deviceId, status) {