mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-30 14:49:47 +02:00
Fix the incorrect server config being persisted
This commit is contained in:
parent
c1f803bdd0
commit
eb7289c150
2 changed files with 6 additions and 3 deletions
|
@ -51,7 +51,8 @@ public class AbsDatabase: CAPPlugin {
|
||||||
config.token = token
|
config.token = token
|
||||||
|
|
||||||
Store.serverConfig = config
|
Store.serverConfig = config
|
||||||
call.resolve(convertServerConnectionConfigToJSON(config: config))
|
let savedConfig = Store.serverConfig // Fetch the latest value
|
||||||
|
call.resolve(convertServerConnectionConfigToJSON(config: savedConfig!))
|
||||||
}
|
}
|
||||||
@objc func removeServerConnectionConfig(_ call: CAPPluginCall) {
|
@objc func removeServerConnectionConfig(_ call: CAPPluginCall) {
|
||||||
let id = call.getString("serverConnectionConfigId", "")
|
let id = call.getString("serverConnectionConfigId", "")
|
||||||
|
|
|
@ -33,6 +33,8 @@ class Database {
|
||||||
NSLog("failed to update server config")
|
NSLog("failed to update server config")
|
||||||
debugPrint(error)
|
debugPrint(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLastActiveConfigIndex(index: existing.index)
|
||||||
} else {
|
} else {
|
||||||
if config.index == 0 {
|
if config.index == 0 {
|
||||||
let lastConfig: ServerConnectionConfig? = realm.objects(ServerConnectionConfig.self).last
|
let lastConfig: ServerConnectionConfig? = realm.objects(ServerConnectionConfig.self).last
|
||||||
|
@ -52,10 +54,10 @@ class Database {
|
||||||
NSLog("failed to save server config")
|
NSLog("failed to save server config")
|
||||||
debugPrint(exception)
|
debugPrint(exception)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setLastActiveConfigIndex(index: config.index)
|
setLastActiveConfigIndex(index: config.index)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func deleteServerConnectionConfig(id: String) {
|
public func deleteServerConnectionConfig(id: String) {
|
||||||
let realm = try! Realm()
|
let realm = try! Realm()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue