Add events to resync UI to actual config

This also provide fixup for UI no aligning to changed config when coming from cli up with config flags.
This commit is contained in:
riccardom
2026-06-03 22:59:01 +02:00
parent 029e69279c
commit 1100cea6a4
3 changed files with 49 additions and 9 deletions

View File

@@ -1150,6 +1150,17 @@ func (s *serviceClient) onTrayReady() {
s.onUpdateAvailable(newVersion, enforced)
}
})
s.eventManager.AddHandler(func(event *proto.SystemEvent) {
// Daemon emits a config_changed event after every engine spawn
// (Server.Start, Server.Up, MDM ticker restart). Re-sync the
// tray submenu checkboxes from the fresh daemon-side config so
// the user does not have to restart the tray to see CLI- or
// MDM-driven changes.
if event.Category == proto.SystemEvent_SYSTEM && event.Metadata["type"] == "config_changed" {
log.Infof("config_changed event received (source=%s); refreshing settings", event.Metadata["source"])
s.loadSettings()
}
})
go s.eventManager.Start(s.ctx)
go s.eventHandler.listen(s.ctx)