fix: stale display outputs leaking between pages in web UI
Bug: when the StreamDeck was on a non-main page (e.g. dashboard) and the web UI was opened in a private browser tab, the frontend defaulted to the first page in config while display outputs from the other page were still applied to keys sharing the same index. Fix 1 (backend): send the current active page via SSE immediately on new client connection so the frontend knows the correct page from the start. Fix 2 (frontend): only apply display output text/background to keys that have a display config, preventing cross-page leakage.
This commit is contained in:
+3
-3
@@ -181,8 +181,8 @@ document.addEventListener('alpine:init', () => {
|
||||
hasDisplay: !!(kc?.display),
|
||||
hasAction: !!(kc?.actions?.length),
|
||||
actionTypes: this.getActionTypes(kc?.actions || []),
|
||||
displayBg: dout?.background || '',
|
||||
displayText: dout?.text || '',
|
||||
displayBg: (kc?.display && dout?.background) || '',
|
||||
displayText: (kc?.display && dout?.text) || '',
|
||||
previewUrl: this.keyPreviewUrl(kc ? kc : {}, dout),
|
||||
isDynamic: !!(page.dynamic_keys && page.effective_keys?.find(k => k.index === i)),
|
||||
})
|
||||
@@ -204,7 +204,7 @@ document.addEventListener('alpine:init', () => {
|
||||
const k = kc || {}
|
||||
let url = '/api/render?key_size=72'
|
||||
if (k.icon) url += `&icon=${encodeURIComponent(k.icon)}`
|
||||
const label = dout?.text || this.displayOutputs[k.index]?.text || k.label
|
||||
const label = (k.display && (dout?.text || this.displayOutputs[k.index]?.text)) || k.label
|
||||
if (label) url += `&label=${encodeURIComponent(label)}`
|
||||
if (k.icon_scale != null) url += `&icon_scale=${k.icon_scale}`
|
||||
if (k.font_size != null) url += `&font_size=${k.font_size}`
|
||||
|
||||
@@ -172,6 +172,14 @@ func (s *WebServer) handleSSE(w http.ResponseWriter, r *http.Request) {
|
||||
s.sseClients[ch] = struct{}{}
|
||||
s.sseMu.Unlock()
|
||||
|
||||
s.mu.RLock()
|
||||
if s.pm != nil {
|
||||
if active := s.pm.ActivePageName(); active != "" {
|
||||
ch <- active
|
||||
}
|
||||
}
|
||||
s.mu.RUnlock()
|
||||
|
||||
notify := r.Context().Done()
|
||||
go func() {
|
||||
<-notify
|
||||
|
||||
Reference in New Issue
Block a user