aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-23 15:45:24 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-23 16:11:55 +0530
commit11e44f9ae5b2fa02164053089babb6b326f23634 (patch)
treeb12230b11f8dd63b383236a8cf20e52b53c153f8 /WireGuard/WireGuard
parentiOS: Fix handling of deletion outside app (diff)
downloadwireguard-apple-11e44f9ae5b2fa02164053089babb6b326f23634.tar.xz
wireguard-apple-11e44f9ae5b2fa02164053089babb6b326f23634.zip
iOS: Fix stale tunnel being shown on iPad
When the detail view is shown in the iPad and we delete the current tunnel with a list view swipe rather than the delete button, the detail view should go blank. Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift6
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift8
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift11
3 files changed, 10 insertions, 15 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index 82d10a38..75d82304 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -9,7 +9,7 @@ protocol TunnelsManagerListDelegate: class {
func tunnelAdded(at index: Int)
func tunnelModified(at index: Int)
func tunnelMoved(from oldIndex: Int, to newIndex: Int)
- func tunnelRemoved(at index: Int)
+ func tunnelRemoved(at index: Int, tunnel: TunnelContainer)
}
protocol TunnelsManagerActivationDelegate: class {
@@ -65,7 +65,7 @@ class TunnelsManager {
if !loadedTunnelProviders.contains(where: { $0.tunnelConfiguration == currentTunnel.tunnelConfiguration }) {
// Tunnel was deleted outside the app
self.tunnels.remove(at: index)
- self.tunnelsListDelegate?.tunnelRemoved(at: index)
+ self.tunnelsListDelegate?.tunnelRemoved(at: index, tunnel: currentTunnel)
}
}
for loadedTunnelProvider in loadedTunnelProviders {
@@ -212,7 +212,7 @@ class TunnelsManager {
if let self = self {
let index = self.tunnels.firstIndex(of: tunnel)!
self.tunnels.remove(at: index)
- self.tunnelsListDelegate?.tunnelRemoved(at: index)
+ self.tunnelsListDelegate?.tunnelRemoved(at: index, tunnel: tunnel)
}
completionHandler(nil)
}
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
index 9531c171..867eda76 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
@@ -239,14 +239,6 @@ extension TunnelDetailTableViewController {
return
}
}
- if self.splitViewController?.isCollapsed != false {
- self.navigationController?.navigationController?.popToRootViewController(animated: true)
- } else {
- let detailVC = UIViewController()
- detailVC.view.backgroundColor = .white
- let detailNC = UINavigationController(rootViewController: detailVC)
- self.showDetailViewController(detailNC, sender: self)
- }
}
}
return cell
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
index 6a2f3a1c..ccef4cd7 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
@@ -31,6 +31,8 @@ class TunnelsListTableViewController: UIViewController {
return busyIndicator
}()
+ var detailDisplayedTunnel: TunnelContainer?
+
override func loadView() {
view = UIView()
view.backgroundColor = .white
@@ -217,6 +219,7 @@ extension TunnelsListTableViewController: UITableViewDelegate {
let tunnelDetailNC = UINavigationController(rootViewController: tunnelDetailVC)
tunnelDetailNC.restorationIdentifier = "DetailNC"
showDetailViewController(tunnelDetailNC, sender: self) // Shall get propagated up to the split-vc
+ detailDisplayedTunnel = tunnel
}
func tableView(_ tableView: UITableView,
@@ -251,19 +254,19 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
tableView.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0))
}
- func tunnelRemoved(at index: Int) {
- let selectedIndex = tableView.indexPathForSelectedRow?.row
+ func tunnelRemoved(at index: Int, tunnel: TunnelContainer) {
tableView.deleteRows(at: [IndexPath(row: index, section: 0)], with: .automatic)
centeredAddButton.isHidden = tunnelsManager?.numberOfTunnels() ?? 0 > 0
- if let selectedIndex = selectedIndex, selectedIndex == index, let splitViewController = splitViewController {
+ if detailDisplayedTunnel == tunnel, let splitViewController = splitViewController {
if splitViewController.isCollapsed != false {
- (splitViewController.viewControllers[0] as? UINavigationController)?.popViewController(animated: false)
+ (splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
} else {
let detailVC = UIViewController()
detailVC.view.backgroundColor = .white
let detailNC = UINavigationController(rootViewController: detailVC)
splitViewController.showDetailViewController(detailNC, sender: self)
}
+ detailDisplayedTunnel = nil
if let presentedNavController = self.presentedViewController as? UINavigationController, presentedNavController.viewControllers.first is TunnelEditTableViewController {
self.presentedViewController?.dismiss(animated: false, completion: nil)
}