audiobookshelf-atv/ios/App/Shared/util/Store.swift

29 lines
670 B
Swift
Raw Normal View History

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 {
private static var _serverConfig: ServerConnectionConfig?
2022-04-15 08:16:11 +00:00
public static var serverConfig: ServerConnectionConfig? {
2022-04-11 14:29:19 +00:00
get {
2022-04-15 08:16:11 +00:00
return _serverConfig
2022-04-11 14:29:19 +00:00
}
set(updated) {
2022-04-15 08:16:11 +00:00
if updated != nil {
2022-05-03 10:55:13 +00:00
Database.shared.setServerConnectionConfig(config: updated!)
2022-04-15 08:16:11 +00:00
} else {
2022-05-03 10:55:13 +00:00
Database.shared.setLastActiveConfigIndexToNil()
2022-04-15 08:16:11 +00:00
}
2022-08-10 21:08:19 +00:00
// Make safe for accessing on all threads
_serverConfig = updated?.freeze()
2022-04-11 14:29:19 +00:00
}
}
}