advplyr.audiobookshelf-app/ios/App/Shared/util/Store.swift

32 lines
907 B
Swift
Raw Normal View History

2022-04-11 16:29:19 +02:00
//
// Store.swift
// App
//
// Created by Rasmus Krämer on 11.04.22.
//
import Foundation
import RealmSwift
class Store {
2022-04-12 14:28:47 +02:00
private static var _serverConfig: ServerConnectionConfig?
2022-04-11 16:30:13 +02:00
// ONLY USE REALM IN Database.realmQueue OR ELSE THE APP WILL CRASH
2022-04-11 16:29:19 +02:00
public static var serverConfig: ServerConnectionConfig {
get {
2022-04-12 14:28:47 +02:00
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()
2022-04-11 16:29:19 +02:00
}
set(updated) {
Database.setServerConnectionConfig(config: updated)
2022-04-12 14:28:47 +02:00
_serverConfig = updated
2022-04-11 16:29:19 +02:00
}
}
}