add settings menu item to check for updates immediately

This commit is contained in:
Drew Weymouth
2023-03-30 19:19:01 -07:00
parent d59352cd4d
commit 06cd393b8c
2 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -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())
+9 -2
View File
@@ -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)
})
}