aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-05 18:24:45 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:33 +0530
commitf3c29042418942f9e07281aefbc67360ebc4366f (patch)
tree14eda4b4b07dee8eb75b47afc3f64b850055458f /WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
parentmacOS: Present tunnel activation errors from the window when possible (diff)
downloadwireguard-apple-f3c29042418942f9e07281aefbc67360ebc4366f.tar.xz
wireguard-apple-f3c29042418942f9e07281aefbc67360ebc4366f.zip
macOS: Manage tunnels: Handle the case when there are no tunnels
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift17
1 files changed, 9 insertions, 8 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 643529c..dff583a 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -5,7 +5,7 @@ import Cocoa
protocol TunnelsListTableViewControllerDelegate: class {
func tunnelSelected(tunnel: TunnelContainer)
- func tunnelListEmpty()
+ func tunnelsListEmpty()
}
class TunnelsListTableViewController: NSViewController {
@@ -61,7 +61,10 @@ class TunnelsListTableViewController: NSViewController {
override func loadView() {
tableView.dataSource = self
tableView.delegate = self
- selectTunnel(at: 0)
+ let isSelected = selectTunnel(at: 0)
+ if !isSelected {
+ delegate?.tunnelsListEmpty()
+ }
let scrollView = NSScrollView()
scrollView.hasVerticalScroller = true
@@ -246,6 +249,9 @@ extension TunnelsListTableViewController {
func tunnelRemoved(at index: Int) {
tableView.removeRows(at: IndexSet(integer: index), withAnimation: .slideLeft)
+ if tunnelsManager.numberOfTunnels() == 0 {
+ delegate?.tunnelsListEmpty()
+ }
}
}
@@ -263,12 +269,7 @@ extension TunnelsListTableViewController: NSTableViewDelegate {
}
func tableViewSelectionDidChange(_ notification: Notification) {
- guard tableView.selectedRow >= 0 else {
- if tunnelsManager.numberOfTunnels() == 0 {
- delegate?.tunnelListEmpty()
- }
- return
- }
+ guard tableView.selectedRow >= 0 else { return }
let selectedTunnel = tunnelsManager.tunnel(at: tableView.selectedRow)
delegate?.tunnelSelected(tunnel: selectedTunnel)
}