From 06cd393b8c7ae70a822244fca690d3bf3824581c Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Thu, 30 Mar 2023 19:04:04 -0700 Subject: [PATCH] add settings menu item to check for updates immediately --- backend/updatechecker.go | 4 ++-- ui/mainwindow.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/updatechecker.go b/backend/updatechecker.go index 7b71925..21e8236 100644 --- a/backend/updatechecker.go +++ b/backend/updatechecker.go @@ -52,7 +52,7 @@ func (u *UpdateChecker) LatestReleaseURL() *url.URL { } func (u *UpdateChecker) checkForUpdate() { - t := u.latestVersionTag() + t := u.CheckLatestVersionTag() if t != "" && t != *u.lastCheckedTag { u.versionTagFound = t if u.OnUpdatedVersionFound != nil { @@ -61,7 +61,7 @@ func (u *UpdateChecker) checkForUpdate() { } } -func (u *UpdateChecker) latestVersionTag() string { +func (u *UpdateChecker) CheckLatestVersionTag() string { resp, err := http.Head(u.latestReleaseURL) if err != nil { log.Printf("failed to check for newest version: %s", err.Error()) diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 9fecb5e..e06520d 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -2,7 +2,6 @@ package ui import ( "fmt" - "log" "supersonic/backend" "supersonic/res" "supersonic/ui/browsing" @@ -98,6 +97,15 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap m.Controller.PromptForLoginAndConnect() }) m.BrowsingPane.AddSettingsMenuItem("Log Out", app.ServerManager.Logout) + m.BrowsingPane.AddSettingsMenuItem("Check for Updates", func() { + if t := app.UpdateChecker.CheckLatestVersionTag(); t != "" && t != app.VersionTag() { + m.ShowNewVersionDialog(appName, t) + } else { + dialog.ShowInformation("No new version found", + "You are running the latest version of "+appName, + m.Window) + } + }) m.BrowsingPane.AddSettingsMenuItem("About...", m.Controller.ShowAboutDialog) m.addNavigationButtons() m.BrowsingPane.DisableNavigationButtons() @@ -116,7 +124,6 @@ func (m *MainWindow) ShowNewVersionDialog(appName, versionTag string) { fyne.CurrentApp().OpenURL(m.App.UpdateChecker.LatestReleaseURL()) } m.App.Config.Application.LastCheckedVersion = versionTag - log.Printf("reset version: %s", m.App.Config.Application.LastCheckedVersion) }, m.Window) }) }