Show error when adding password with same name

This commit is contained in:
Bob Sun 2017-03-02 17:26:12 +08:00
parent 2d50a40370
commit bdc2cfaaa8
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 38 additions and 9 deletions

View file

@ -78,15 +78,23 @@ class PasswordsViewController: UIViewController, UITableViewDataSource, UITableV
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.show(withStatus: "Saving")
DispatchQueue.global(qos: .userInitiated).async {
PasswordStore.shared.add(password: controller.password!, progressBlock: { progress in
do {
try PasswordStore.shared.add(password: controller.password!, progressBlock: { progress in
DispatchQueue.main.async {
SVProgressHUD.showProgress(progress, status: "Encrypting")
}
})
DispatchQueue.main.async {
SVProgressHUD.showProgress(progress, status: "Encrypting")
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
}
} catch {
DispatchQueue.main.async {
SVProgressHUD.showError(withStatus: error.localizedDescription)
SVProgressHUD.dismiss(withDelay: 1)
}
})
DispatchQueue.main.async {
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
}
}
}