Skip to content

Commit

Permalink
Merge branch 'feature/hide-account-id' into beta-2.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Sep 11, 2024
2 parents ae70f00 + 8c12360 commit 536ab25
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions IVPNClient/Scenes/AccountScreen/AccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
5 changes: 3 additions & 2 deletions IVPNClient/Scenes/AccountScreen/View/AccountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AccountView: UITableView {

// MARK: - Properties -

var isAccountHidden = true
private var serviceType = ServiceType.getType(currentPlan: Application.shared.serviceStatus.currentPlan)

// MARK: - Methods -
Expand All @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -262,18 +261,13 @@ 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])
shared.register(defaults: [Key.keepAlive: true])
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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 536ab25

Please sign in to comment.