Fix #696: Save and use last selected library when re-connecting to server

This commit is contained in:
Drew Weymouth
2025-09-04 08:19:00 -07:00
parent e090244704
commit 81205d65c3
3 changed files with 23 additions and 10 deletions
+4 -3
View File
@@ -25,9 +25,10 @@ type ServerConnection struct {
type ServerConfig struct {
ServerConnection
ID uuid.UUID
Nickname string
Default bool
ID uuid.UUID
Nickname string
Default bool
SelectedLibrary string
}
type AppConfig struct {
+3 -3
View File
@@ -29,7 +29,7 @@ type ServerManager struct {
appName string
appVersion string
config *Config
onServerConnected []func()
onServerConnected []func(*ServerConfig)
onLogout []func()
}
@@ -62,7 +62,7 @@ func (s *ServerManager) ConnectToServer(conf *ServerConfig, password string) err
s.ServerID = conf.ID
s.SetDefaultServer(s.ServerID)
for _, cb := range s.onServerConnected {
cb()
cb(conf)
}
return nil
}
@@ -152,7 +152,7 @@ func (s *ServerManager) deleteServerPassword(serverID uuid.UUID) {
}
// Sets a callback that is invoked when a server is connected to.
func (s *ServerManager) OnServerConnected(cb func()) {
func (s *ServerManager) OnServerConnected(cb func(*ServerConfig)) {
s.onServerConnected = append(s.onServerConnected, cb)
}