Refetch Init after EventConfigChanged for live UI updates (#1011)

This commit is contained in:
James Read 2026-05-10 22:10:10 +01:00 committed by GitHub
commit 31b70018a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 1 deletions

View File

@ -50,6 +50,27 @@ async function reconnectWebsocket () {
}, RECONNECT_DELAY_MS)
}
async function refreshInitAfterConfigChange () {
if (!window.client) {
return
}
try {
window.initResponse = await window.client.init({})
if (typeof window.updateHeaderFromInit === 'function') {
window.updateHeaderFromInit()
}
} catch (err) {
console.error('Failed to refresh config from server after EventConfigChanged:', err)
}
}
async function handleConfigChangedEvent (j) {
await refreshInitAfterConfigChange()
window.dispatchEvent(j)
}
function handleEvent (msg) {
const typeName = msg.event.value.$typeName.replace('olivetin.api.v1.', '')
@ -57,8 +78,12 @@ function handleEvent (msg) {
j.payload = msg.event.value
switch (typeName) {
case 'EventOutputChunk':
case 'EventConfigChanged':
handleConfigChangedEvent(j).catch((err) => {
console.error('EventConfigChanged handler failed:', err)
})
break
case 'EventOutputChunk':
case 'EventEntityChanged':
window.dispatchEvent(j)
break