diff --git a/IVPNClient/Scenes/AccountScreen/AccountViewController.swift b/IVPNClient/Scenes/AccountScreen/AccountViewController.swift index 108819e2..48992e63 100644 --- a/IVPNClient/Scenes/AccountScreen/AccountViewController.swift +++ b/IVPNClient/Scenes/AccountScreen/AccountViewController.swift @@ -78,9 +78,9 @@ class AccountViewController: UITableViewController { } @IBAction func toggleAccountHidden(_ sender: Any) { - let hidden = UserDefaults.shared.isAccountHidden + let hidden = accountView.isAccountHidden accountView.toggleAccountVisibility(hide: !hidden) - UserDefaults.shared.set(!hidden, forKey: UserDefaults.Key.isAccountHidden) + accountView.isAccountHidden = !hidden } // MARK: - View Lifecycle - diff --git a/IVPNClient/Scenes/AccountScreen/View/AccountView.swift b/IVPNClient/Scenes/AccountScreen/View/AccountView.swift index 63229774..eaf74bc7 100644 --- a/IVPNClient/Scenes/AccountScreen/View/AccountView.swift +++ b/IVPNClient/Scenes/AccountScreen/View/AccountView.swift @@ -41,6 +41,7 @@ class AccountView: UITableView { // MARK: - Properties - + var isAccountHidden = true private var serviceType = ServiceType.getType(currentPlan: Application.shared.serviceStatus.currentPlan) // MARK: - Methods - @@ -59,12 +60,12 @@ class AccountView: UITableView { header.frame = CGRect(x: 0, y: 0, width: Int(header.frame.width), height: headerHeight) reloadData() layoutIfNeeded() - toggleAccountVisibility(hide: UserDefaults.shared.isAccountHidden) + toggleAccountVisibility(hide: isAccountHidden) } func initQRCode(viewModel: AccountViewModel) { qrCodeImage.image = UIImage.generateQRCode(from: viewModel.accountId) - toggleAccountVisibility(hide: UserDefaults.shared.isAccountHidden) + toggleAccountVisibility(hide: isAccountHidden) } func toggleAccountVisibility(hide: Bool) { diff --git a/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift b/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift index 551e40c5..ec4449b0 100644 --- a/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift +++ b/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift @@ -95,7 +95,6 @@ extension UserDefaults { static let v2rayProtocol = "v2rayProtocol" static let isV2ray = "isV2ray" static let disableWidgetPrompt = "disableWidgetPrompt" - static let isAccountHidden = "isAccountHidden" } @objc dynamic var wireguardTunnelProviderError: String { @@ -262,10 +261,6 @@ extension UserDefaults { return bool(forKey: Key.disableWidgetPrompt) } - @objc dynamic var isAccountHidden: Bool { - return bool(forKey: Key.isAccountHidden) - } - static func registerUserDefaults() { shared.register(defaults: [Key.networkProtectionUntrustedConnect: true]) shared.register(defaults: [Key.networkProtectionTrustedDisconnect: true]) @@ -273,7 +268,6 @@ extension UserDefaults { shared.register(defaults: [Key.wgRegenerationRate: Config.wgKeyRegenerationRate]) shared.register(defaults: [Key.wgKeyTimestamp: Date()]) shared.register(defaults: [Key.serversSort: "city"]) - shared.register(defaults: [Key.isAccountHidden: true]) standard.register(defaults: [Key.selectedServerFastest: true]) standard.register(defaults: [Key.showIPv4Servers: true]) standard.register(defaults: [Key.preventSameCountryMultiHop: true]) @@ -308,7 +302,6 @@ extension UserDefaults { shared.removeObject(forKey: Key.v2rayProtocol) shared.removeObject(forKey: Key.isV2ray) shared.removeObject(forKey: Key.disableWidgetPrompt) - shared.removeObject(forKey: Key.isAccountHidden) standard.removeObject(forKey: Key.serviceStatus) standard.removeObject(forKey: Key.selectedHost) standard.removeObject(forKey: Key.selectedExitHost)