mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-25 21:04:02 +02:00
Add version to ServerConnectionConfig on iOS
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -13,6 +13,7 @@ class ServerConnectionConfig: Object {
|
||||
@Persisted(indexed: true) var index: Int = 1
|
||||
@Persisted var name: String = ""
|
||||
@Persisted var address: String = ""
|
||||
@Persisted var version: String = ""
|
||||
@Persisted var userId: String = ""
|
||||
@Persisted var username: String = ""
|
||||
@Persisted var token: String = ""
|
||||
@@ -29,6 +30,7 @@ func convertServerConnectionConfigToJSON(config: ServerConnectionConfig) -> Dict
|
||||
"name": config.name,
|
||||
"index": config.index,
|
||||
"address": config.address,
|
||||
"version": config.version,
|
||||
"userId": config.userId,
|
||||
"username": config.username,
|
||||
"token": config.token,
|
||||
|
||||
@@ -27,6 +27,7 @@ class Database {
|
||||
try existing.update {
|
||||
existing.name = config.name
|
||||
existing.address = config.address
|
||||
existing.version = config.version
|
||||
existing.userId = config.userId
|
||||
existing.username = config.username
|
||||
existing.token = config.token
|
||||
|
||||
Reference in New Issue
Block a user