diff --git a/enzevalos_iphone/AuthenticationModel.swift b/enzevalos_iphone/AuthenticationModel.swift index 6be2e8a2408a2aa095476659d1d769fb3ec150c1..d9ee43dbc12ba9d5d549df77563cccb63a543a77 100644 --- a/enzevalos_iphone/AuthenticationModel.swift +++ b/enzevalos_iphone/AuthenticationModel.swift @@ -11,7 +11,7 @@ import Combine class AuthenticationModel: NSObject { - enum AuthenticationResult {case Success, Timeout, Error} + enum AuthenticationResult {case Success, Timeout, Error(value: MailServerConnectionError)} static let instance: AuthenticationModel = AuthenticationModel() @@ -50,7 +50,6 @@ class AuthenticationModel: NSObject { let result = self.dispatchGroup.wait(timeout: DispatchTime.now() + timeoutDelay) DispatchQueue.main.async { promise(.success(self.onTimeout(timeoutResult: result))) - print("promise sent") } } } @@ -120,7 +119,15 @@ class AuthenticationModel: NSObject { if imapConfigurationSuccessful && smtpConfigurationSuccessful { return AuthenticationResult.Success } else { - return AuthenticationResult.Error + var error = MailServerConnectionError.AuthenticationError + if let smtp = currentIMAP, let e = MailServerConnectionError.findPrioError(errors: smtp.errors) { + error = e + } + if let imap = currentIMAP, let e = MailServerConnectionError.findPrioError(errors: imap.errors) { + error = e + } + + return AuthenticationResult.Error(value: error) } } else { return AuthenticationResult.Timeout diff --git a/enzevalos_iphone/AuthenticationViewModel.swift b/enzevalos_iphone/AuthenticationViewModel.swift index bd8a755187dcf4ce27a626aedf5db4919293ba11..d9ec6d7cc3f80025b4549d5a469c61780352f48e 100644 --- a/enzevalos_iphone/AuthenticationViewModel.swift +++ b/enzevalos_iphone/AuthenticationViewModel.swift @@ -31,7 +31,7 @@ class AuthenticationViewModel : ObservableObject { case AuthenticationModel.AuthenticationResult.Error : self.authenticationFailed(error: MailServerConnectionError.AuthenticationError) case AuthenticationModel.AuthenticationResult.Timeout : - self.timeoutNotification(result: promise) + self.timeoutNotification() } } } @@ -43,10 +43,10 @@ class AuthenticationViewModel : ObservableObject { switch promise { case AuthenticationModel.AuthenticationResult.Success : self.authenticationSucceed() - case AuthenticationModel.AuthenticationResult.Error : - self.authenticationFailed(error: MailServerConnectionError.AuthenticationError) + case AuthenticationModel.AuthenticationResult.Error(let value) : + self.authenticationFailed(error: value) case AuthenticationModel.AuthenticationResult.Timeout : - self.timeoutNotification(result: promise) + self.timeoutNotification() } } } @@ -72,7 +72,7 @@ class AuthenticationViewModel : ObservableObject { case AuthenticationModel.AuthenticationResult.Error : self.authenticationFailed(error: MailServerConnectionError.AuthenticationError) case AuthenticationModel.AuthenticationResult.Timeout : - self.timeoutNotification(result: promise) + self.timeoutNotification() } } }) @@ -86,8 +86,7 @@ class AuthenticationViewModel : ObservableObject { errorMessage = NSLocalizedString(error.localizedUIBodyString, comment: "") } - func timeoutNotification(result: AuthenticationModel.AuthenticationResult) { - print("promise arrived") + func timeoutNotification() { errorMessage = NSLocalizedString(MailServerConnectionError.TimeoutError.localizedUIBodyString, comment: "") } }