Add version to ServerConnectionConfig on iOS

This commit is contained in:
advplyr
2025-07-05 14:28:02 -05:00
parent 52f86cbce9
commit 5804c54656
7 changed files with 37 additions and 8 deletions
+9 -4
View File
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
let configuration = Realm.Configuration(
schemaVersion: 19,
schemaVersion: 20,
migrationBlock: { [weak self] migration, oldSchemaVersion in
if (oldSchemaVersion < 1) {
self?.logger.log("Realm schema version was \(oldSchemaVersion)")
@@ -65,9 +65,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding disableSleepTimerFadeOut settings")
migration.enumerateObjects(ofType: PlayerSettings.className()) { oldObject, newObject in
newObject?["disableSleepTimerFadeOut"] = false
}
}
}
}
if (oldSchemaVersion < 20) {
self?.logger.log("Realm schema version was \(oldSchemaVersion)... Adding version to ServerConnectionConfigs")
migration.enumerateObjects(ofType: ServerConnectionConfig.className()) { oldObject, newObject in
newObject?["version"] = ""
}
}
}
)
Realm.Configuration.defaultConfiguration = configuration
+17
View File
@@ -53,11 +53,17 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
@objc func setCurrentServerConnectionConfig(_ call: CAPPluginCall) {
var id = call.getString("id")
let address = call.getString("address", "")
let version = call.getString("version", "")
let userId = call.getString("userId", "")
let username = call.getString("username", "")
let token = call.getString("token", "")
let refreshToken = call.getString("refreshToken", "") // Refresh only sent after login or refresh
let name = "\(address) (\(username))"
if (refreshToken != "") {
// TODO: Implement secure storage
}
if id == nil {
id = "\(address)@\(username)".toBase64()
@@ -68,6 +74,7 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
config.index = 0
config.name = name
config.address = address
config.version = version
config.userId = userId
config.username = username
config.token = token
@@ -82,6 +89,16 @@ public class AbsDatabase: CAPPlugin, CAPBridgedPlugin {
call.resolve()
}
@objc func getRefreshToken(_ call: CAPPluginCall) {
let serverConnectionConfigId = call.getString("serverConnectionConfigId", "")
// TODO: Implement secure storage
call.resolve()
}
@objc func clearRefreshToken(_ call: CAPPluginCall) {
let serverConnectionConfigId = call.getString("serverConnectionConfigId", "")
// TODO: Implement secure storage
call.resolve()
}
@objc func logout(_ call: CAPPluginCall) {
Store.serverConfig = nil
call.resolve()