summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2023-07-21 18:03:21 +0200
committerEmīls <emils@mullvad.net>2023-07-21 18:03:21 +0200
commitc6c09e0fc9e2e5d36d4446e605d5d8fc41e486fc (patch)
treeccb3f77906464ceccd3a7d86cb1292ffd6a9c55d
parent1785459e9db5af6a7302a0a826351e5d310edb45 (diff)
parent6c265b9f819bfae7ba8def7bfe3c0d639042dd00 (diff)
downloadmullvadvpn-c6c09e0fc9e2e5d36d4446e605d5d8fc41e486fc.tar.xz
mullvadvpn-c6c09e0fc9e2e5d36d4446e605d5d8fc41e486fc.zip
Merge branch 'settings-wiped-is-new-flag-ios-234'
-rw-r--r--ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift16
1 files changed, 15 insertions, 1 deletions
diff --git a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
index c7d3b7dbc7..fd5b8a5c55 100644
--- a/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
+++ b/ios/MullvadVPN/SettingsManager/TunnelSettingsV2.swift
@@ -43,7 +43,7 @@ struct StoredAccountData: Codable, Equatable {
/// Account expiry.
var expiry: Date
- /// be set `true` when account is created and be flipped to `false` when user adds more credit
+ /// Set to `true` when the account is created and flipped to `false` when the user adds more credit.
var isNew = false
/// Returns `true` if account has expired.
@@ -52,6 +52,20 @@ struct StoredAccountData: Codable, Equatable {
}
}
+extension StoredAccountData {
+ init(from decoder: Decoder) throws {
+ let container = try decoder.container(keyedBy: CodingKeys.self)
+ self.identifier = try container.decode(String.self, forKey: .identifier)
+ self.number = try container.decode(String.self, forKey: .number)
+ self.expiry = try container.decode(Date.self, forKey: .expiry)
+
+ // When the app is upgraded from 2023.3 or below, this field won't exist, and the auto synthesized init will fail.
+ // This leads to a reset of the settings. If the key isn't present, consider the account not new to avoid the issue.
+ let isNewAccount = try? container.decode(Bool.self, forKey: .isNew)
+ self.isNew = isNewAccount ?? false
+ }
+}
+
enum DeviceState: Codable, Equatable {
case loggedIn(StoredAccountData, StoredDeviceData)
case loggedOut