mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
cleanly migrate the server URL value to a JSON array (ie coming from 1.135.0 app)
This commit is contained in:
parent
88e008c4c2
commit
0a90f490f2
@ -65,7 +65,7 @@ class ImmichAPI {
|
|||||||
init() async throws {
|
init() async throws {
|
||||||
// fetch the credentials from the UserDefaults store that dart placed here
|
// fetch the credentials from the UserDefaults store that dart placed here
|
||||||
guard let defaults = UserDefaults(suiteName: "group.app.immich.share"),
|
guard let defaults = UserDefaults(suiteName: "group.app.immich.share"),
|
||||||
let serverURL = defaults.string(forKey: "widget_server_url"),
|
var serverURL = defaults.string(forKey: "widget_server_url"),
|
||||||
let sessionKey = defaults.string(forKey: "widget_auth_token")
|
let sessionKey = defaults.string(forKey: "widget_auth_token")
|
||||||
else {
|
else {
|
||||||
throw WidgetError.noLogin
|
throw WidgetError.noLogin
|
||||||
@ -75,8 +75,13 @@ class ImmichAPI {
|
|||||||
throw WidgetError.noLogin
|
throw WidgetError.noLogin
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the stored value is an array of URLs
|
// migrate the server list value to a JSON array if it is not already
|
||||||
if serverURL.starts(with: "[") {
|
if !serverURL.starts(with: "[") {
|
||||||
|
let newServerList = "[\"\(serverURL)\"]"
|
||||||
|
defaults.set(newServerList, forKey: "widget_server_url")
|
||||||
|
serverURL = newServerList
|
||||||
|
}
|
||||||
|
|
||||||
guard let urls = try? JSONDecoder().decode([String].self, from: serverURL.data(using: .utf8)!) else {
|
guard let urls = try? JSONDecoder().decode([String].self, from: serverURL.data(using: .utf8)!) else {
|
||||||
throw WidgetError.noLogin
|
throw WidgetError.noLogin
|
||||||
}
|
}
|
||||||
@ -94,12 +99,6 @@ class ImmichAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw WidgetError.fetchFailed
|
throw WidgetError.fetchFailed
|
||||||
} else {
|
|
||||||
serverConfig = ServerConfig(
|
|
||||||
serverEndpoint: serverURL,
|
|
||||||
sessionKey: sessionKey
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static func validateServer(at endpointURL: URL) async -> URL? {
|
private static func validateServer(at endpointURL: URL) async -> URL? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user