Improve edit password to make it consistent with Pass

This commit is contained in:
Bob Sun 2017-04-25 13:01:17 -07:00
parent 86cb8a84cd
commit 055ea243a3
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
6 changed files with 136 additions and 103 deletions

View file

@ -212,28 +212,26 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
@IBAction private func saveEditPassword(segue: UIStoryboardSegue) {
if self.password!.changed {
if self.password!.changed != 0 {
SVProgressHUD.show(withStatus: "Saving")
DispatchQueue.global(qos: .userInitiated).async {
do {
self.passwordEntity = try self.passwordStore.update(passwordEntity: self.passwordEntity!, password: self.password!)
} catch {
DispatchQueue.main.async {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
}
DispatchQueue.main.async {
self.setTableData()
self.tableView.reloadData()
SVProgressHUD.showSuccess(withStatus: "Success")
SVProgressHUD.dismiss(withDelay: 1)
}
do {
self.passwordEntity = try self.passwordStore.edit(passwordEntity: self.passwordEntity!, password: self.password!)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
self.setTableData()
self.tableView.reloadData()
SVProgressHUD.showSuccess(withStatus: "Success")
SVProgressHUD.dismiss(withDelay: 1)
}
}
@IBAction private func deletePassword(segue: UIStoryboardSegue) {
passwordStore.delete(passwordEntity: passwordEntity!)
do {
try passwordStore.delete(passwordEntity: passwordEntity!)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
let _ = navigationController?.popViewController(animated: true)
}
@ -387,20 +385,14 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
// commit the change of HOTP counter
if password!.changed {
DispatchQueue.global(qos: .userInitiated).async {
do {
self.passwordEntity = try self.passwordStore.update(passwordEntity: self.passwordEntity!, password: self.password!)
} catch {
DispatchQueue.main.async {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
}
DispatchQueue.main.async {
SVProgressHUD.showSuccess(withStatus: "Password Copied\nCounter Updated")
SVProgressHUD.dismiss(withDelay: 1)
}
if password!.changed != 0 {
do {
self.passwordEntity = try self.passwordStore.edit(passwordEntity: self.passwordEntity!, password: self.password!)
} catch {
Utils.alert(title: "Error", message: error.localizedDescription, controller: self, completion: nil)
}
SVProgressHUD.showSuccess(withStatus: "Password Copied\nCounter Updated")
SVProgressHUD.dismiss(withDelay: 1)
}
}