From dfc4b37518144f711aaab8e92e316e0ba87c6460 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Fri, 4 Jan 2019 18:33:46 +0530 Subject: macOS: Manage tunnels: Update tunnels list on changes Signed-off-by: Roopesh Chander --- .../TunnelsListTableViewController.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift') diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index 2d0b6fe..c7d691f 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -206,6 +206,24 @@ class TunnelsListTableViewController: NSViewController { } } +extension TunnelsListTableViewController { + func tunnelAdded(at index: Int) { + tableView.insertRows(at: IndexSet(integer: index), withAnimation: .slideLeft) + } + + func tunnelModified(at index: Int) { + tableView.reloadData(forRowIndexes: IndexSet(integer: index), columnIndexes: IndexSet(integer: 0)) + } + + func tunnelMoved(from oldIndex: Int, to newIndex: Int) { + tableView.moveRow(at: oldIndex, to: newIndex) + } + + func tunnelRemoved(at index: Int) { + tableView.removeRows(at: IndexSet(integer: index), withAnimation: .slideLeft) + } +} + extension TunnelsListTableViewController: NSTableViewDataSource { func numberOfRows(in tableView: NSTableView) -> Int { return tunnelsManager.numberOfTunnels() -- cgit v1.2.3-59-g8ed1b