mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 10:04:39 +02:00
Fix persisting active config
This commit is contained in:
parent
f6c43e479d
commit
a7424cc428
3 changed files with 12 additions and 13 deletions
|
@ -76,21 +76,16 @@ class Database {
|
|||
}
|
||||
}
|
||||
|
||||
public func setLastActiveConfigIndexToNil() {
|
||||
Database.realmQueue.sync {
|
||||
setLastActiveConfigIndex(index: nil)
|
||||
}
|
||||
private func setLastActiveConfigIndexToNil() {
|
||||
setLastActiveConfigIndex(index: nil)
|
||||
}
|
||||
|
||||
public func setLastActiveConfigIndex(index: Int?) {
|
||||
let existing = instance.objects(ServerConnectionConfigActiveIndex.self)
|
||||
var obj = ServerConnectionConfigActiveIndex()
|
||||
obj.index = index
|
||||
|
||||
private func setLastActiveConfigIndex(index: Int?) {
|
||||
do {
|
||||
try instance.write {
|
||||
instance.delete(existing)
|
||||
instance.add(obj)
|
||||
var existing = instance.objects(ServerConnectionConfigActiveIndex.self).last ?? ServerConnectionConfigActiveIndex(index: index)
|
||||
existing.index = index
|
||||
instance.add(existing, update: .modified)
|
||||
}
|
||||
} catch(let exception) {
|
||||
NSLog("failed to save server config active index")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue