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