macOS: Simplify reusing of the detail VC when applicable

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-04-04 12:24:25 +05:30
parent 6e6a6b88fb
commit 6015661beb
1 changed files with 2 additions and 12 deletions

View File

@ -86,12 +86,7 @@ extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegat
setTunnelDetailContentVC(tunnelDetailVC) setTunnelDetailContentVC(tunnelDetailVC)
self.tunnelDetailVC = tunnelDetailVC self.tunnelDetailVC = tunnelDetailVC
} else { } else {
let unusableTunnelDetailVC: UnusableTunnelDetailViewController let unusableTunnelDetailVC = tunnelDetailContentVC as? UnusableTunnelDetailViewController ?? UnusableTunnelDetailViewController()
if let unusableTunnelContentVC = tunnelDetailContentVC as? UnusableTunnelDetailViewController {
unusableTunnelDetailVC = unusableTunnelContentVC
} else {
unusableTunnelDetailVC = UnusableTunnelDetailViewController()
}
unusableTunnelDetailVC.onButtonClicked = { [weak tunnelsListVC] in unusableTunnelDetailVC.onButtonClicked = { [weak tunnelsListVC] in
tunnelsListVC?.handleRemoveTunnelAction() tunnelsListVC?.handleRemoveTunnelAction()
} }
@ -99,12 +94,7 @@ extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegat
self.tunnelDetailVC = nil self.tunnelDetailVC = nil
} }
} else if tunnelIndices.count > 1 { } else if tunnelIndices.count > 1 {
let multiSelectionVC: ButtonedDetailViewController let multiSelectionVC = tunnelDetailContentVC as? ButtonedDetailViewController ?? ButtonedDetailViewController()
if let buttonedDetailVC = tunnelDetailContentVC as? ButtonedDetailViewController {
multiSelectionVC = buttonedDetailVC
} else {
multiSelectionVC = ButtonedDetailViewController()
}
multiSelectionVC.setButtonTitle(tr(format: "macButtonDeleteTunnels (%d)", tunnelIndices.count)) multiSelectionVC.setButtonTitle(tr(format: "macButtonDeleteTunnels (%d)", tunnelIndices.count))
multiSelectionVC.onButtonClicked = { [weak tunnelsListVC] in multiSelectionVC.onButtonClicked = { [weak tunnelsListVC] in
tunnelsListVC?.handleRemoveTunnelAction() tunnelsListVC?.handleRemoveTunnelAction()