mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-03 17:44:51 +02:00
support multiple servers
This commit is contained in:
parent
9a7b2e8172
commit
29fd29728a
8 changed files with 68 additions and 38 deletions
|
@ -10,20 +10,17 @@ import RealmSwift
|
|||
|
||||
class Store {
|
||||
@ThreadSafe private static var _serverConfig: ServerConnectionConfig?
|
||||
public static var serverConfig: ServerConnectionConfig {
|
||||
public static var serverConfig: ServerConnectionConfig? {
|
||||
get {
|
||||
if _serverConfig == nil {
|
||||
let index = Database.getActiveServerConfigIndex()
|
||||
// TODO: change this when multiple configs are possible
|
||||
_serverConfig = Database.getServerConnectionConfigs().first { config in
|
||||
return config.index == index
|
||||
}
|
||||
}
|
||||
|
||||
return _serverConfig ?? ServerConnectionConfig()
|
||||
return _serverConfig
|
||||
}
|
||||
set(updated) {
|
||||
Database.setServerConnectionConfig(config: updated)
|
||||
if updated != nil {
|
||||
Database.setServerConnectionConfig(config: updated!)
|
||||
} else {
|
||||
Database.setLastActiveConfigIndexToNil()
|
||||
}
|
||||
|
||||
_serverConfig = nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue