add settings menu item to check for updates immediately
This commit is contained in:
@@ -52,7 +52,7 @@ func (u *UpdateChecker) LatestReleaseURL() *url.URL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpdateChecker) checkForUpdate() {
|
func (u *UpdateChecker) checkForUpdate() {
|
||||||
t := u.latestVersionTag()
|
t := u.CheckLatestVersionTag()
|
||||||
if t != "" && t != *u.lastCheckedTag {
|
if t != "" && t != *u.lastCheckedTag {
|
||||||
u.versionTagFound = t
|
u.versionTagFound = t
|
||||||
if u.OnUpdatedVersionFound != nil {
|
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)
|
resp, err := http.Head(u.latestReleaseURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to check for newest version: %s", err.Error())
|
log.Printf("failed to check for newest version: %s", err.Error())
|
||||||
|
|||||||
+9
-2
@@ -2,7 +2,6 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
"supersonic/res"
|
"supersonic/res"
|
||||||
"supersonic/ui/browsing"
|
"supersonic/ui/browsing"
|
||||||
@@ -98,6 +97,15 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap
|
|||||||
m.Controller.PromptForLoginAndConnect()
|
m.Controller.PromptForLoginAndConnect()
|
||||||
})
|
})
|
||||||
m.BrowsingPane.AddSettingsMenuItem("Log Out", app.ServerManager.Logout)
|
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.BrowsingPane.AddSettingsMenuItem("About...", m.Controller.ShowAboutDialog)
|
||||||
m.addNavigationButtons()
|
m.addNavigationButtons()
|
||||||
m.BrowsingPane.DisableNavigationButtons()
|
m.BrowsingPane.DisableNavigationButtons()
|
||||||
@@ -116,7 +124,6 @@ func (m *MainWindow) ShowNewVersionDialog(appName, versionTag string) {
|
|||||||
fyne.CurrentApp().OpenURL(m.App.UpdateChecker.LatestReleaseURL())
|
fyne.CurrentApp().OpenURL(m.App.UpdateChecker.LatestReleaseURL())
|
||||||
}
|
}
|
||||||
m.App.Config.Application.LastCheckedVersion = versionTag
|
m.App.Config.Application.LastCheckedVersion = versionTag
|
||||||
log.Printf("reset version: %s", m.App.Config.Application.LastCheckedVersion)
|
|
||||||
}, m.Window)
|
}, m.Window)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user