mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-28 06:14:00 +02:00
added removeServerConnectionConfig method
This commit is contained in:
@@ -11,9 +11,7 @@ import RealmSwift
|
||||
class Database {
|
||||
// All DB releated actions must be executed on "realm-queue"
|
||||
public static let realmQueue = DispatchQueue(label: "realm-queue")
|
||||
private static var instance: Realm = {
|
||||
try! Realm(queue: realmQueue)
|
||||
}()
|
||||
private static var instance: Realm = try! Realm(queue: realmQueue)
|
||||
|
||||
public static func setServerConnectionConfig(config: ServerConnectionConfig) {
|
||||
var refrence: ThreadSafeReference<ServerConnectionConfig>?
|
||||
@@ -57,6 +55,22 @@ class Database {
|
||||
setLastActiveConfigIndex(index: config.index)
|
||||
}
|
||||
}
|
||||
public static func deleteServerConnectionConfig(id: String) {
|
||||
realmQueue.sync {
|
||||
let config = instance.object(ofType: ServerConnectionConfig.self, forPrimaryKey: id)
|
||||
|
||||
do {
|
||||
try instance.write {
|
||||
if config != nil {
|
||||
instance.delete(config!)
|
||||
}
|
||||
}
|
||||
} catch(let exception) {
|
||||
NSLog("failed to delete server config")
|
||||
debugPrint(exception)
|
||||
}
|
||||
}
|
||||
}
|
||||
public static func getServerConnectionConfigs() -> [ServerConnectionConfig] {
|
||||
var refrences: [ThreadSafeReference<ServerConnectionConfig>] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user