From 7a257bc9cab7a4d7aed3bf144f1bf66a2066eecf Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 7 Aug 2019 12:46:56 -0700 Subject: [PATCH] Presents confirmation alert when signing out of Delta Sync --- .../SyncingServicesViewController.swift | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Delta/Settings/Syncing/SyncingServicesViewController.swift b/Delta/Settings/Syncing/SyncingServicesViewController.swift index bdba6ae..f2c0c25 100644 --- a/Delta/Settings/Syncing/SyncingServicesViewController.swift +++ b/Delta/Settings/Syncing/SyncingServicesViewController.swift @@ -189,22 +189,28 @@ extension SyncingServicesViewController case .authenticate: if SyncManager.shared.coordinator?.account != nil { - SyncManager.shared.deauthenticate { (result) in - DispatchQueue.main.async { - do - { - try result.get() - self.tableView.reloadData() - - Settings.syncingService = nil - } - catch - { - let alertController = UIAlertController(title: NSLocalizedString("Failed to Sign Out", comment: ""), error: error) - self.present(alertController, animated: true, completion: nil) + 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) + alertController.addAction(.cancel) + alertController.addAction(UIAlertAction(title: NSLocalizedString("Sign Out", comment: ""), style: .destructive) { (action) in + SyncManager.shared.deauthenticate { (result) in + DispatchQueue.main.async { + do + { + try result.get() + self.tableView.reloadData() + + Settings.syncingService = 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 { @@ -230,6 +236,8 @@ extension SyncingServicesViewController } } } + + tableView.deselectRow(at: indexPath, animated: true) } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int