macOS: reload: Iterate in reverse

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-01-22 19:57:35 +05:30
parent 704de3b26c
commit 54f45cb3f8
1 changed files with 3 additions and 5 deletions

View File

@ -61,13 +61,11 @@ class TunnelsManager {
let loadedTunnelProviders = managers ?? []
var numberOfRemovedTunnels = 0
for (index, currentTunnel) in self.tunnels.enumerated() {
for (index, currentTunnel) in self.tunnels.enumerated().reversed() {
if !loadedTunnelProviders.contains(where: { $0.tunnelConfiguration == currentTunnel.tunnelConfiguration }) {
// Tunnel was deleted outside the app
self.tunnels.remove(at: index - numberOfRemovedTunnels)
self.tunnelsListDelegate?.tunnelRemoved(at: index - numberOfRemovedTunnels)
numberOfRemovedTunnels += 1
self.tunnels.remove(at: index)
self.tunnelsListDelegate?.tunnelRemoved(at: index)
}
}
for loadedTunnelProvider in loadedTunnelProviders {