From c955c5a9138829accd3572b9e6a4301ea826d1ce Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Mon, 29 Oct 2018 04:54:57 +0530 Subject: [PATCH] VPN: Fix deletion of tunnels Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/VPN/TunnelsManager.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuard/VPN/TunnelsManager.swift b/WireGuard/WireGuard/VPN/TunnelsManager.swift index d320e1d..bfecfd6 100644 --- a/WireGuard/WireGuard/VPN/TunnelsManager.swift +++ b/WireGuard/WireGuard/VPN/TunnelsManager.swift @@ -9,6 +9,7 @@ protocol TunnelsManagerDelegate: class { func tunnelAdded(at: Int) func tunnelModified(at: Int) func tunnelsChanged() + func tunnelRemoved(at: Int) } enum TunnelsManagerError: Error { @@ -145,7 +146,7 @@ class TunnelsManager { tunnelProviderManager.removeFromPreferences { [weak self] (error) in defer { self?.isDeletingTunnel = false } - guard (error != nil) else { + guard (error == nil) else { completionHandler(error) return } @@ -154,6 +155,7 @@ class TunnelsManager { s.tunnels[i].index = s.tunnels[i].index + 1 } s.tunnels.remove(at: tunnelIndex) + s.delegate?.tunnelRemoved(at: tunnelIndex) } completionHandler(nil) }