VPN: Fix deletion of tunnels

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-29 04:54:57 +05:30
parent 7f77d87e27
commit c955c5a913
1 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ protocol TunnelsManagerDelegate: class {
func tunnelAdded(at: Int) func tunnelAdded(at: Int)
func tunnelModified(at: Int) func tunnelModified(at: Int)
func tunnelsChanged() func tunnelsChanged()
func tunnelRemoved(at: Int)
} }
enum TunnelsManagerError: Error { enum TunnelsManagerError: Error {
@ -145,7 +146,7 @@ class TunnelsManager {
tunnelProviderManager.removeFromPreferences { [weak self] (error) in tunnelProviderManager.removeFromPreferences { [weak self] (error) in
defer { self?.isDeletingTunnel = false } defer { self?.isDeletingTunnel = false }
guard (error != nil) else { guard (error == nil) else {
completionHandler(error) completionHandler(error)
return return
} }
@ -154,6 +155,7 @@ class TunnelsManager {
s.tunnels[i].index = s.tunnels[i].index + 1 s.tunnels[i].index = s.tunnels[i].index + 1
} }
s.tunnels.remove(at: tunnelIndex) s.tunnels.remove(at: tunnelIndex)
s.delegate?.tunnelRemoved(at: tunnelIndex)
} }
completionHandler(nil) completionHandler(nil)
} }