move saving play queue to window close intercept instead of app exit in case we crash during exit tasks
This commit is contained in:
+13
-9
@@ -341,15 +341,6 @@ func (a *App) Shutdown() {
|
||||
}
|
||||
a.MPRISHandler.Shutdown()
|
||||
a.PlaybackManager.DisableCallbacks()
|
||||
if a.Config.Application.SavePlayQueue {
|
||||
var queueServer mediaprovider.CanSavePlayQueue = nil
|
||||
if a.Config.Application.SaveQueueToServer {
|
||||
if qs, ok := a.ServerManager.Server.(mediaprovider.CanSavePlayQueue); ok {
|
||||
queueServer = qs
|
||||
}
|
||||
}
|
||||
SavePlayQueue(a.ServerManager.ServerID.String(), a.PlaybackManager, path.Join(a.configDir, savedQueueFile), queueServer)
|
||||
}
|
||||
a.PlaybackManager.Stop() // will trigger scrobble check
|
||||
a.Config.LocalPlayback.Volume = a.LocalPlayer.GetVolume()
|
||||
a.cancel()
|
||||
@@ -357,6 +348,19 @@ func (a *App) Shutdown() {
|
||||
a.Config.WriteConfigFile(a.configFilePath())
|
||||
}
|
||||
|
||||
func (a *App) SavePlayQueueIfEnabled() {
|
||||
if !a.Config.Application.SavePlayQueue {
|
||||
return
|
||||
}
|
||||
var queueServer mediaprovider.CanSavePlayQueue = nil
|
||||
if a.Config.Application.SaveQueueToServer {
|
||||
if qs, ok := a.ServerManager.Server.(mediaprovider.CanSavePlayQueue); ok {
|
||||
queueServer = qs
|
||||
}
|
||||
}
|
||||
SavePlayQueue(a.ServerManager.ServerID.String(), a.PlaybackManager, path.Join(a.configDir, savedQueueFile), queueServer)
|
||||
}
|
||||
|
||||
func (a *App) LoadSavedPlayQueue() error {
|
||||
queueFilePath := path.Join(a.configDir, savedQueueFile)
|
||||
queue, err := LoadPlayQueue(queueFilePath, a.ServerManager, a.Config.Application.SaveQueueToServer)
|
||||
|
||||
@@ -140,6 +140,7 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
m.Window.SetContent(fynetooltip.AddWindowToolTipLayer(m.container, m.Window.Canvas()))
|
||||
m.setInitialSize()
|
||||
m.Window.SetCloseIntercept(func() {
|
||||
app.SavePlayQueueIfEnabled()
|
||||
m.SaveWindowSize()
|
||||
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
||||
m.Window.Hide()
|
||||
|
||||
Reference in New Issue
Block a user