summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-04-08 13:19:08 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-04-28 10:25:01 +0200
commit9677345d004cb78f6b174f24c161623bd518cdee (patch)
tree81666163365c33a9c1c23fe541cb3b82f9dd5c23
parentfb6e9174c1a3fdafe145d70b54001b1875e2974e (diff)
downloadmullvadvpn-9677345d004cb78f6b174f24c161623bd518cdee.tar.xz
mullvadvpn-9677345d004cb78f6b174f24c161623bd518cdee.zip
Settings: add AccountObserver
-rw-r--r--ios/MullvadVPN/SettingsViewController.swift26
1 files changed, 17 insertions, 9 deletions
diff --git a/ios/MullvadVPN/SettingsViewController.swift b/ios/MullvadVPN/SettingsViewController.swift
index 58a382e60e..723f3c1828 100644
--- a/ios/MullvadVPN/SettingsViewController.swift
+++ b/ios/MullvadVPN/SettingsViewController.swift
@@ -13,7 +13,7 @@ protocol SettingsViewControllerDelegate: class {
func settingsViewControllerDidFinish(_ controller: SettingsViewController)
}
-class SettingsViewController: UITableViewController {
+class SettingsViewController: UITableViewController, AccountObserver {
weak var delegate: SettingsViewControllerDelegate?
@@ -59,16 +59,24 @@ class SettingsViewController: UITableViewController {
navigationItem.largeTitleDisplayMode = .always
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(handleDismiss))
- accountExpiryObserver = NotificationCenter.default.addObserver(
- forName: Account.didUpdateAccountExpiryNotification,
- object: Account.shared,
- queue: OperationQueue.main) { [weak self] (note) in
- guard let accountRow = self?.accountRow else { return }
+ Account.shared.addObserver(self)
+ setupDataSource()
+ }
- self?.staticDataSource.reloadRows([accountRow], with: .none)
- }
+ // MARK: - AccountObserver
- setupDataSource()
+ func account(_ account: Account, didUpdateExpiry expiry: Date) {
+ guard let accountRow = accountRow else { return }
+
+ staticDataSource.reloadRows([accountRow], with: .none)
+ }
+
+ func account(_ account: Account, didLoginWithToken token: String, expiry: Date) {
+ // no-op
+ }
+
+ func accountDidLogout(_ account: Account) {
+ // no-op
}
// MARK: - IBActions