Fix VPN toggle enabling despite errors

This commit is contained in:
Davide De Rosa 2022-04-26 19:01:55 +02:00
parent e10f33717d
commit f4714dec58
1 changed files with 6 additions and 3 deletions

View File

@ -39,8 +39,10 @@ struct VPNToggle: View {
.init {
isLocallyEnabled
} set: {
guard toggleVPN() else {
return
}
isLocallyEnabled = $0
toggleVPN()
}
}
@ -65,9 +67,9 @@ struct VPNToggle: View {
}.disabled(!canToggle)
}
private func toggleVPN() {
private func toggleVPN() -> Bool {
guard vpnManager.toggle() else {
return
return false
}
// rate limit toggle actions
@ -77,5 +79,6 @@ struct VPNToggle: View {
}
onToggle?()
return true
}
}