From 6015661beb57aa922d096713c19e71009d33ab6b Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 4 Apr 2019 12:24:25 +0530 Subject: [PATCH] macOS: Simplify reusing of the detail VC when applicable Signed-off-by: Roopesh Chander --- .../ManageTunnelsRootViewController.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift index de41963..b388843 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift @@ -86,12 +86,7 @@ extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegat setTunnelDetailContentVC(tunnelDetailVC) self.tunnelDetailVC = tunnelDetailVC } else { - let unusableTunnelDetailVC: UnusableTunnelDetailViewController - if let unusableTunnelContentVC = tunnelDetailContentVC as? UnusableTunnelDetailViewController { - unusableTunnelDetailVC = unusableTunnelContentVC - } else { - unusableTunnelDetailVC = UnusableTunnelDetailViewController() - } + let unusableTunnelDetailVC = tunnelDetailContentVC as? UnusableTunnelDetailViewController ?? UnusableTunnelDetailViewController() unusableTunnelDetailVC.onButtonClicked = { [weak tunnelsListVC] in tunnelsListVC?.handleRemoveTunnelAction() } @@ -99,12 +94,7 @@ extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegat self.tunnelDetailVC = nil } } else if tunnelIndices.count > 1 { - let multiSelectionVC: ButtonedDetailViewController - if let buttonedDetailVC = tunnelDetailContentVC as? ButtonedDetailViewController { - multiSelectionVC = buttonedDetailVC - } else { - multiSelectionVC = ButtonedDetailViewController() - } + let multiSelectionVC = tunnelDetailContentVC as? ButtonedDetailViewController ?? ButtonedDetailViewController() multiSelectionVC.setButtonTitle(tr(format: "macButtonDeleteTunnels (%d)", tunnelIndices.count)) multiSelectionVC.onButtonClicked = { [weak tunnelsListVC] in tunnelsListVC?.handleRemoveTunnelAction()