Tunnel editing: Delegate should also report when editing is cancelled

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-25 11:14:38 +05:30
parent 05b9d6972b
commit f7feb18ea8
3 changed files with 13 additions and 5 deletions

View File

@ -54,10 +54,13 @@ class TunnelDetailTableViewController: UITableViewController {
// MARK: TunnelEditTableViewControllerDelegate
extension TunnelDetailTableViewController: TunnelEditTableViewControllerDelegate {
func saved(tunnel: TunnelContainer) {
func tunnelSaved(tunnel: TunnelContainer) {
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
self.tableView.reloadData()
}
func tunnelEditingCancelled() {
// Nothing to do
}
}
// MARK: UITableViewDataSource

View File

@ -4,7 +4,8 @@
import UIKit
protocol TunnelEditTableViewControllerDelegate: class {
func saved(tunnel: TunnelContainer)
func tunnelSaved(tunnel: TunnelContainer)
func tunnelEditingCancelled()
}
// MARK: TunnelEditTableViewController
@ -81,8 +82,8 @@ class TunnelEditTableViewController: UITableViewController {
print("Could not modify tunnel: \(error)")
self?.showErrorAlert(title: "Could not save", message: "Internal error")
} else {
self?.delegate?.saved(tunnel: tunnel)
self?.dismiss(animated: true, completion: nil)
self?.delegate?.tunnelSaved(tunnel: tunnel)
}
}
} else {
@ -92,8 +93,8 @@ class TunnelEditTableViewController: UITableViewController {
print("Could not add tunnel: \(error)")
self?.showErrorAlert(title: "Could not save", message: "Internal error")
} else {
self?.delegate?.saved(tunnel: tunnel)
self?.dismiss(animated: true, completion: nil)
self?.delegate?.tunnelSaved(tunnel: tunnel)
}
}
}
@ -102,6 +103,7 @@ class TunnelEditTableViewController: UITableViewController {
@objc func cancelTapped() {
dismiss(animated: true, completion: nil)
self.delegate?.tunnelEditingCancelled()
}
func showErrorAlert(title: String, message: String) {

View File

@ -94,12 +94,15 @@ class TunnelsListTableViewController: UITableViewController {
// MARK: TunnelEditTableViewControllerDelegate
extension TunnelsListTableViewController: TunnelEditTableViewControllerDelegate {
func saved(tunnel: TunnelContainer) {
func tunnelSaved(tunnel: TunnelContainer) {
guard let tunnelsManager = tunnelsManager else { return }
let tunnelDetailVC = TunnelDetailTableViewController(tunnelsManager: tunnelsManager,
tunnel: tunnel)
showDetailViewController(tunnelDetailVC, sender: self) // Shall get propagated up to the split-vc
}
func tunnelEditingCancelled() {
// Nothing to do here
}
}
// MARK: UITableViewDataSource