Polish the "discard all local changes" feature
This commit is contained in:
parent
5ea9a3118b
commit
9d653acc0d
1 changed files with 4 additions and 2 deletions
|
|
@ -35,13 +35,15 @@ class AdvancedSettingsTableViewController: UITableViewController {
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
} else if tableView.cellForRow(at: indexPath) == discardChangesTableViewCell {
|
} 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)
|
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 Changesa", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in
|
alert.addAction(UIAlertAction(title: "Discard All Changes", style: UIAlertActionStyle.destructive, handler: {[unowned self] (action) -> Void in
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
SVProgressHUD.show(withStatus: "Resetting ...")
|
SVProgressHUD.show(withStatus: "Resetting ...")
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
do {
|
do {
|
||||||
let numberDiscarded = try PasswordStore.shared.reset()
|
let numberDiscarded = try PasswordStore.shared.reset()
|
||||||
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded")))
|
if numberDiscarded > 0 {
|
||||||
|
NotificationCenter.default.post(Notification(name: Notification.Name("passwordStoreChangeDiscarded")))
|
||||||
|
}
|
||||||
self.navigationController!.popViewController(animated: true)
|
self.navigationController!.popViewController(animated: true)
|
||||||
SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits")
|
SVProgressHUD.showSuccess(withStatus: "Discarded \(numberDiscarded) commits")
|
||||||
SVProgressHUD.dismiss(withDelay: 1)
|
SVProgressHUD.dismiss(withDelay: 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue