diff --git a/pass/Controllers/AdvancedSettingsTableViewController.swift b/pass/Controllers/AdvancedSettingsTableViewController.swift index 2ede296..e805b88 100644 --- a/pass/Controllers/AdvancedSettingsTableViewController.swift +++ b/pass/Controllers/AdvancedSettingsTableViewController.swift @@ -57,8 +57,7 @@ class AdvancedSettingsTableViewController: UITableViewController { SVProgressHUD.dismiss(withDelay: 1) } catch { DispatchQueue.main.async { - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } diff --git a/pass/Controllers/PasswordsViewController.swift b/pass/Controllers/PasswordsViewController.swift index 302e6a0..65a7939 100644 --- a/pass/Controllers/PasswordsViewController.swift +++ b/pass/Controllers/PasswordsViewController.swift @@ -96,8 +96,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } } catch { DispatchQueue.main.async { - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } @@ -136,8 +135,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } } catch { DispatchQueue.main.async { - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } @@ -325,8 +323,7 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV } catch { print(error) DispatchQueue.main.async { - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } diff --git a/pass/Controllers/SSHKeySettingTableViewController.swift b/pass/Controllers/SSHKeySettingTableViewController.swift index d04fde0..ad14dd0 100644 --- a/pass/Controllers/SSHKeySettingTableViewController.swift +++ b/pass/Controllers/SSHKeySettingTableViewController.swift @@ -49,9 +49,7 @@ class SSHKeySettingTableViewController: UITableViewController { try Data(contentsOf: Defaults[.gitRepositorySSHPublicKeyURL]!).write(to: Globals.sshPublicKeyURL, options: .atomic) try Data(contentsOf: Defaults[.gitRepositorySSHPrivateKeyURL]!).write(to: Globals.sshPrivateKeyURL, options: .atomic) } catch { - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) - print(error) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } navigationController!.popViewController(animated: true) diff --git a/pass/Controllers/SettingsTableViewController.swift b/pass/Controllers/SettingsTableViewController.swift index c05f53e..754b404 100644 --- a/pass/Controllers/SettingsTableViewController.swift +++ b/pass/Controllers/SettingsTableViewController.swift @@ -53,8 +53,7 @@ class SettingsTableViewController: UITableViewController { } catch { DispatchQueue.main.async { self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } @@ -84,8 +83,7 @@ class SettingsTableViewController: UITableViewController { } catch { DispatchQueue.main.async { self.pgpKeyTableViewCell.detailTextLabel?.text = "Not Set" - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } } @@ -155,9 +153,7 @@ class SettingsTableViewController: UITableViewController { } } catch { DispatchQueue.main.async { - print(error) - SVProgressHUD.showError(withStatus: error.localizedDescription) - SVProgressHUD.dismiss(withDelay: 1) + Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil) } } diff --git a/pass/Helpers/Utils.swift b/pass/Helpers/Utils.swift index 1278f24..726e107 100644 --- a/pass/Helpers/Utils.swift +++ b/pass/Helpers/Utils.swift @@ -10,6 +10,7 @@ import Foundation import SwiftyUserDefaults import KeychainAccess import UIKit +import SVProgressHUD class Utils { static func removeFileIfExists(atPath path: String) { @@ -65,6 +66,7 @@ class Utils { } static func alert(title: String, message: String, controller: UIViewController, completion: (() -> Void)?) { + SVProgressHUD.dismiss() let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)) controller.present(alert, animated: true, completion: completion)