From b2ad15da55f594b4d3b1a997f4024e6e8280350d Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 25 Oct 2018 11:14:38 +0530 Subject: [PATCH] Tunnel editing: Delegate should also report when editing is cancelled --- .../UI/iOS/TunnelDetailTableViewController.swift | 5 ++++- .../WireGuard/UI/iOS/TunnelEditTableViewController.swift | 8 +++++--- .../WireGuard/UI/iOS/TunnelsListTableViewController.swift | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift index 1ca6ec6..b4ae135 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift @@ -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 diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index 1c863f5..1054cfa 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -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) { diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index 0500f18..e88ec91 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -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