Presents confirmation alert when signing out of Delta Sync

This commit is contained in:
Riley Testut 2019-08-07 12:46:56 -07:00
parent 6e6c7a68bd
commit 7a257bc9ca

View File

@ -189,22 +189,28 @@ extension SyncingServicesViewController
case .authenticate: case .authenticate:
if SyncManager.shared.coordinator?.account != nil if SyncManager.shared.coordinator?.account != nil
{ {
SyncManager.shared.deauthenticate { (result) in let alertController = UIAlertController(title: NSLocalizedString("Are you sure you want to sign out?", comment: ""), message: NSLocalizedString("Signing in again later may result in conflicts that must be resolved manually.", comment: ""), preferredStyle: .actionSheet)
DispatchQueue.main.async { alertController.addAction(.cancel)
do alertController.addAction(UIAlertAction(title: NSLocalizedString("Sign Out", comment: ""), style: .destructive) { (action) in
{ SyncManager.shared.deauthenticate { (result) in
try result.get() DispatchQueue.main.async {
self.tableView.reloadData() do
{
Settings.syncingService = nil try result.get()
} self.tableView.reloadData()
catch
{ Settings.syncingService = nil
let alertController = UIAlertController(title: NSLocalizedString("Failed to Sign Out", comment: ""), error: error) }
self.present(alertController, animated: true, completion: nil) catch
{
let alertController = UIAlertController(title: NSLocalizedString("Failed to Sign Out", comment: ""), error: error)
self.present(alertController, animated: true, completion: nil)
}
} }
} }
} })
self.present(alertController, animated: true, completion: nil)
} }
else else
{ {
@ -230,6 +236,8 @@ extension SyncingServicesViewController
} }
} }
} }
tableView.deselectRow(at: indexPath, animated: true)
} }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int