From 19f16c3291a9ef95a58d396105979ec7ddfa8f9f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 14 Dec 2018 00:01:50 +0100 Subject: [PATCH] Deduplicate functions --- WireGuard/WireGuard/Tunnel/TunnelsManager.swift | 2 +- WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift index 64e65ae..4abc3c0 100644 --- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift +++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift @@ -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) } diff --git a/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift b/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift index 6d57006..0145fda 100644 --- a/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift +++ b/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift @@ -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) {