Deduplicate functions
This commit is contained in:
parent
628ba73aa3
commit
19f16c3291
|
@ -45,7 +45,7 @@ enum TunnelsManagerActivationError: WireGuardAppError {
|
|||
var alertText: AlertText {
|
||||
switch self {
|
||||
case .activationFailed:
|
||||
return ("Activation failure", "The tunnel could not be activated. Please ensure you are connected to the Internet.")
|
||||
return ("Activation failure", "The tunnel could not be activated. Please ensure that you are connected to the Internet.")
|
||||
case .activationFailedWithExtensionError(let title, let message):
|
||||
return (title, message)
|
||||
}
|
||||
|
|
|
@ -6,16 +6,8 @@ import os.log
|
|||
|
||||
class ErrorPresenter {
|
||||
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?, onPresented: (() -> Void)? = nil, onDismissal: (() -> Void)? = nil) {
|
||||
guard let sourceVC = sourceVC else { return }
|
||||
|
||||
let (title, message) = error.alertText
|
||||
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
|
||||
onDismissal?()
|
||||
}
|
||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||
alert.addAction(okAction)
|
||||
|
||||
sourceVC.present(alert, animated: true, completion: onPresented)
|
||||
showErrorAlert(title: title, message: message, from: sourceVC, onPresented: onPresented, onDismissal: onDismissal)
|
||||
}
|
||||
|
||||
static func showErrorAlert(title: String, message: String, from sourceVC: UIViewController?, onPresented: (() -> Void)? = nil, onDismissal: (() -> Void)? = nil) {
|
||||
|
|
Loading…
Reference in New Issue