Add manual update check to tray menu, /update/check endpoint
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled

- Tray 'Check for Updates' now checks immediately and shows dialog
- Dialog has 'Install' and 'Later' buttons
- /update/check endpoint on local server for SPA to query
This commit is contained in:
2026-07-14 00:25:35 +02:00
parent 23535eac25
commit bcef4e6456

View File

@@ -267,6 +267,31 @@ h1{font-size:18px;margin-bottom:8px}.ok{color:#22c55e;font-size:14px}</style>
json.NewEncoder(w).Encode(cfg) json.NewEncoder(w).Encode(cfg)
}) })
mux.HandleFunc("/update/check", func(w http.ResponseWriter, r *http.Request) {
latest := fetchLatestRelease()
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")
if latest == nil {
json.NewEncoder(w).Encode(map[string]string{"current": version})
return
}
hasAsset := false
for _, a := range latest.Assets {
if strings.Contains(a.Name, "darwin") {
hasAsset = true
updater.mu.Lock()
updater.latestURL = a.BrowserDownloadURL
updater.mu.Unlock()
break
}
}
json.NewEncoder(w).Encode(map[string]string{
"current": version,
"latest": latest.Version,
"has_asset": fmt.Sprintf("%t", hasAsset),
})
})
listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", oidcCallbackPort)) listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", oidcCallbackPort))
if err != nil { if err != nil {
log.Printf("OIDC server: %v", err) log.Printf("OIDC server: %v", err)
@@ -683,7 +708,30 @@ func main() {
}) })
trayMenu.AddSeparator() trayMenu.AddSeparator()
trayMenu.Add("Check for Updates").OnClick(func(ctx *application.Context) { trayMenu.Add("Check for Updates").OnClick(func(ctx *application.Context) {
go checkUpdates() go func() {
latest := fetchLatestRelease()
if latest == nil {
app.Dialog.Info().SetTitle("Up to Date").SetMessage("You are running the latest version (" + version + ").").Show()
return
}
for _, a := range latest.Assets {
if strings.Contains(a.Name, "darwin") {
updater.mu.Lock()
updater.latestURL = a.BrowserDownloadURL
updater.mu.Unlock()
msg := fmt.Sprintf("Version %s is available (you have %s). Install now?", latest.Version, version)
d := app.Dialog.Question().SetTitle("Update Available").SetMessage(msg)
yes := d.AddButton("Install")
yes.OnClick(func() { doUpdate(updater.latestURL) })
no := d.AddButton("Later")
d.SetDefaultButton(yes)
d.SetCancelButton(no)
d.Show()
return
}
}
app.Dialog.Info().SetTitle("Up to Date").SetMessage("You are running the latest version (" + version + ").").Show()
}()
}) })
trayMenu.AddSeparator() trayMenu.AddSeparator()
trayMenu.Add("Quit").OnClick(func(ctx *application.Context) { trayMenu.Add("Quit").OnClick(func(ctx *application.Context) {