Polish AdvancedSettingsTableViewController

This commit is contained in:
Mingshen Sun 2017-04-27 21:57:30 -07:00
parent b429a6baf1
commit 2f790d7923
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -60,27 +60,23 @@ class AdvancedSettingsTableViewController: UITableViewController {
} else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell {
let alert = UIAlertController(title: "Discard All Changes?", message: "Do you want to permanently discard all changes to the local copy of your password data? You cannot undo this action.", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Discard All Changes", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in
DispatchQueue.global(qos: .userInitiated).async {
SVProgressHUD.show(withStatus: "Resetting ...")
DispatchQueue.main.async {
do {
let numberDiscarded = try self.passwordStore.reset()
self.navigationController!.popViewController(animated: true)
switch numberDiscarded {
case 0:
SVProgressHUD.showSuccess(withStatus: "No local commits")
case 1:
SVProgressHUD.showSuccess(withStatus: "Discarded 1 commit")
default:
SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits")
}
SVProgressHUD.dismiss(withDelay: 1)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
SVProgressHUD.show(withStatus: "Resetting ...")
do {
let numberDiscarded = try self.passwordStore.reset()
self.navigationController!.popViewController(animated: true)
switch numberDiscarded {
case 0:
SVProgressHUD.showSuccess(withStatus: "No local commits")
case 1:
SVProgressHUD.showSuccess(withStatus: "Discarded 1 commit")
default:
SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits")
}
SVProgressHUD.dismiss(withDelay: 1)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
}))
alert.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.cancel, handler:nil))
self.present(alert, animated: true, completion: nil)