aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift15
1 files changed, 14 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 5ae89c4..46f6bcb 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -61,7 +61,8 @@ class TunnelsListTableViewController: NSViewController {
override func loadView() {
tableView.dataSource = self
tableView.delegate = self
- let isSelected = selectTunnel(at: 0)
+
+ let isSelected = selectTunnelInOperation() || selectTunnel(at: 0)
if !isSelected {
delegate?.tunnelsListEmpty()
}
@@ -110,6 +111,18 @@ class TunnelsListTableViewController: NSViewController {
view = containerView
}
+ override func viewWillAppear() {
+ selectTunnelInOperation()
+ }
+
+ @discardableResult
+ func selectTunnelInOperation() -> Bool {
+ if let currentTunnel = tunnelsManager.tunnelInOperation(), let indexToSelect = tunnelsManager.index(of: currentTunnel) {
+ return selectTunnel(at: indexToSelect)
+ }
+ return false
+ }
+
@objc func buttonBarClicked(sender: AnyObject?) {
guard let buttonBar = sender as? NSSegmentedControl else { return }
// We have to resort to explicitly showing the menu instead of using NSSegmentedControl.setMenu()