macOS: reload: Iterate in reverse
This commit is contained in:
parent
5ddb81b654
commit
b6ad3f39e0
|
@ -61,13 +61,11 @@ class TunnelsManager {
|
||||||
|
|
||||||
let loadedTunnelProviders = managers ?? []
|
let loadedTunnelProviders = managers ?? []
|
||||||
|
|
||||||
var numberOfRemovedTunnels = 0
|
for (index, currentTunnel) in self.tunnels.enumerated().reversed() {
|
||||||
for (index, currentTunnel) in self.tunnels.enumerated() {
|
|
||||||
if !loadedTunnelProviders.contains(where: { $0.tunnelConfiguration == currentTunnel.tunnelConfiguration }) {
|
if !loadedTunnelProviders.contains(where: { $0.tunnelConfiguration == currentTunnel.tunnelConfiguration }) {
|
||||||
// Tunnel was deleted outside the app
|
// Tunnel was deleted outside the app
|
||||||
self.tunnels.remove(at: index - numberOfRemovedTunnels)
|
self.tunnels.remove(at: index)
|
||||||
self.tunnelsListDelegate?.tunnelRemoved(at: index - numberOfRemovedTunnels)
|
self.tunnelsListDelegate?.tunnelRemoved(at: index)
|
||||||
numberOfRemovedTunnels += 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for loadedTunnelProvider in loadedTunnelProviders {
|
for loadedTunnelProvider in loadedTunnelProviders {
|
||||||
|
|
Loading…
Reference in New Issue