summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-10-04 12:32:28 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-10-05 10:18:42 +0200
commit193690bb19f29d8f043bb1dbbb41bc9b540b3348 (patch)
treec45324851057037cbb1b5a5df7a00c634900e152
parentb44a65244abc9b790058871a9a4aa791d3b688ea (diff)
downloadmullvadvpn-193690bb19f29d8f043bb1dbbb41bc9b540b3348.tar.xz
mullvadvpn-193690bb19f29d8f043bb1dbbb41bc9b540b3348.zip
AppDelegate: adapt to new interface
-rw-r--r--ios/MullvadVPN/AppDelegate.swift34
1 files changed, 18 insertions, 16 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift
index cb1bb4518c..8687183d44 100644
--- a/ios/MullvadVPN/AppDelegate.swift
+++ b/ios/MullvadVPN/AppDelegate.swift
@@ -474,40 +474,42 @@ extension AppDelegate: RootContainerViewControllerDelegate {
extension AppDelegate: LoginViewControllerDelegate {
- func loginViewController(_ controller: LoginViewController, loginWithAccountToken accountToken: String, completion: @escaping (Result<AccountResponse, Account.Error>) -> Void) {
+ func loginViewController(_ controller: LoginViewController, loginWithAccountToken accountToken: String, completion: @escaping (Result<REST.AccountResponse, Account.Error>) -> Void) {
self.rootContainer?.setEnableSettingsButton(false)
- Account.shared.login(with: accountToken) { (result) in
- switch result {
- case .success:
+ Account.shared.login(with: accountToken)
+ .onSuccess { _ in
self.logger?.debug("Logged in with existing token")
// RootContainer's settings button will be re-enabled in `loginViewControllerDidLogin`
-
- case .failure(let error):
+ }
+ .onFailure { error in
self.logger?.error(chainedError: error, message: "Failed to log in with existing account")
self.rootContainer?.setEnableSettingsButton(true)
}
+ .observe { promiseCompletion in
+ guard let result = promiseCompletion.unwrappedValue else { return }
- completion(result)
- }
+ completion(result)
+ }
}
- func loginViewControllerLoginWithNewAccount(_ controller: LoginViewController, completion: @escaping (Result<AccountResponse, Account.Error>) -> Void) {
+ func loginViewControllerLoginWithNewAccount(_ controller: LoginViewController, completion: @escaping (Result<REST.AccountResponse, Account.Error>) -> Void) {
self.rootContainer?.setEnableSettingsButton(false)
- Account.shared.loginWithNewAccount { (result) in
- switch result {
- case .success:
+ Account.shared.loginWithNewAccount()
+ .onSuccess { _ in
self.logger?.debug("Logged in with new account token")
// RootContainer's settings button will be re-enabled in `loginViewControllerDidLogin`
-
- case .failure(let error):
+ }
+ .onFailure { error in
self.logger?.error(chainedError: error, message: "Failed to log in with new account")
self.rootContainer?.setEnableSettingsButton(true)
}
+ .observe { promiseCompletion in
+ guard let result = promiseCompletion.unwrappedValue else { return }
- completion(result)
- }
+ completion(result)
+ }
}
func loginViewControllerDidLogin(_ controller: LoginViewController) {