fix: theme reverts to light after an update when the logbook DB is slow

An update can clear the WebView's localStorage; the theme is then restored from
the portable DB pref, but GetUIPref returned ("", nil) while the settings store
was still starting (indistinguishable from a genuinely-unset pref), so the
self-heal gave up after ~2.4s and fell back to the light default.

GetUIPref now returns an error when the settings store isn't wired yet, and the
theme self-heal treats that as "not ready → keep retrying" (up to ~36s) vs a
real empty answer ("unset → keep default"). A dark theme survives the relaunch.
This commit is contained in:
2026-07-23 19:13:00 +02:00
parent e6ca7a8bdd
commit ede9461010
3 changed files with 19 additions and 4 deletions
+7 -1
View File
@@ -1835,7 +1835,13 @@ func (a *App) groupDigitalSlots() bool {
func (a *App) GetUIPref(key string) (string, error) {
if a.settings == nil {
return "", nil
// Distinct from a genuinely-empty pref: the settings store isn't wired yet
// (still connecting the logbook DB — can take seconds on remote MySQL). The
// UI uses the error to keep RETRYING rather than treat it as "unset" and
// fall back to a default (the "dark theme reverts to light after an update"
// bug — localStorage was cleared by the update, and the DB read gave up too
// early while the backend was still starting).
return "", fmt.Errorf("settings store not ready")
}
return a.settings.Get(a.ctx, "ui."+key)
}