don't run post-connect startup tasks more than once

This commit is contained in:
Drew Weymouth
2024-06-02 14:59:05 -07:00
parent 9766aedf7a
commit 859bf2dc17
+16 -9
View File
@@ -51,9 +51,10 @@ type MainWindow struct {
BrowsingPane *browsing.BrowsingPane BrowsingPane *browsing.BrowsingPane
BottomPanel *BottomPanel BottomPanel *BottomPanel
theme *theme.MyTheme theme *theme.MyTheme
haveSystemTray bool haveSystemTray bool
container *fyne.Container alreadyConnected bool // tracks if we have already connected to a server before
container *fyne.Container
// needs to bes shown/hidden when switching between servers based on whether they support radio // needs to bes shown/hidden when switching between servers based on whether they support radio
radioBtn *widget.Button radioBtn *widget.Button
@@ -166,6 +167,17 @@ func (m *MainWindow) RunOnServerConnectedTasks(app *backend.App, displayAppName
}() }()
} }
_, supportsRadio := m.App.ServerManager.Server.(mediaprovider.RadioProvider)
m.radioBtn.Hidden = !supportsRadio
m.radioBtn.Refresh()
m.App.SaveConfigFile()
if m.alreadyConnected {
// below tasks only need to run on first time connecting to a server since launch
return
}
// check if launching new version, else if found available update on startup // check if launching new version, else if found available update on startup
if l := app.Config.Application.LastLaunchedVersion; app.VersionTag() != l { if l := app.Config.Application.LastLaunchedVersion; app.VersionTag() != l {
if !app.IsFirstLaunch() { if !app.IsFirstLaunch() {
@@ -186,12 +198,7 @@ func (m *MainWindow) RunOnServerConnectedTasks(app *backend.App, displayAppName
} }
m.App.Config.Application.LastCheckedVersion = t m.App.Config.Application.LastCheckedVersion = t
} }
m.alreadyConnected = true
_, supportsRadio := m.App.ServerManager.Server.(mediaprovider.RadioProvider)
m.radioBtn.Hidden = !supportsRadio
m.radioBtn.Refresh()
m.App.SaveConfigFile()
} }
func (m *MainWindow) SetupSystemTrayMenu(appName string, fyneApp fyne.App) { func (m *MainWindow) SetupSystemTrayMenu(appName string, fyneApp fyne.App) {