change update password related functions

This commit is contained in:
Bob Sun 2017-02-15 20:01:17 +08:00
parent 8d474677da
commit 869f06e00f
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
4 changed files with 40 additions and 23 deletions

View file

@ -9,6 +9,7 @@
import UIKit
import FavIcon
import SwiftyUserDefaults
import SVProgressHUD
class PasswordDetailTableViewController: UITableViewController, UIGestureRecognizerDelegate {
var passwordEntity: PasswordEntity?
@ -108,13 +109,22 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
}
@IBAction func saveEditPassword(segue: UIStoryboardSegue) {
if password!.changed {
PasswordStore.shared.update(passwordEntity: passwordEntity!, password: password!, progressBlock: { progress in
})
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
setTableData()
tableView.reloadData()
if self.password!.changed {
SVProgressHUD.show(withStatus: "Saving")
DispatchQueue.global(qos: .userInitiated).async {
PasswordStore.shared.update(passwordEntity: self.passwordEntity!, password: self.password!, progressBlock: { progress in
SVProgressHUD.showProgress(progress, status: "Encrypting")
})
DispatchQueue.main.async {
self.passwordEntity!.synced = false
PasswordStore.shared.saveUpdated(passwordEntity: self.passwordEntity!)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
self.setTableData()
self.tableView.reloadData()
SVProgressHUD.showSuccess(withStatus: "Success")
SVProgressHUD.dismiss(withDelay: 1)
}
}
}
}