aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift')
-rw-r--r--WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift28
1 files changed, 15 insertions, 13 deletions
diff --git a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
index a4063933..55b9be28 100644
--- a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
+++ b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
@@ -49,20 +49,22 @@ class ActivateOnDemandViewModel {
}
extension ActivateOnDemandViewModel {
- convenience init(option: ActivateOnDemandOption) {
+ convenience init(tunnel: TunnelContainer) {
self.init()
- switch option {
- case .off:
- break
- case .wiFiInterfaceOnly(let onDemandSSIDOption):
- isWiFiInterfaceEnabled = true
- (ssidOption, selectedSSIDs) = ssidViewModel(from: onDemandSSIDOption)
- case .nonWiFiInterfaceOnly:
- isNonWiFiInterfaceEnabled = true
- case .anyInterface(let onDemandSSIDOption):
- isWiFiInterfaceEnabled = true
- isNonWiFiInterfaceEnabled = true
- (ssidOption, selectedSSIDs) = ssidViewModel(from: onDemandSSIDOption)
+ if tunnel.isActivateOnDemandEnabled {
+ switch tunnel.onDemandOption {
+ case .off:
+ break
+ case .wiFiInterfaceOnly(let onDemandSSIDOption):
+ isWiFiInterfaceEnabled = true
+ (ssidOption, selectedSSIDs) = ssidViewModel(from: onDemandSSIDOption)
+ case .nonWiFiInterfaceOnly:
+ isNonWiFiInterfaceEnabled = true
+ case .anyInterface(let onDemandSSIDOption):
+ isWiFiInterfaceEnabled = true
+ isNonWiFiInterfaceEnabled = true
+ (ssidOption, selectedSSIDs) = ssidViewModel(from: onDemandSSIDOption)
+ }
}
}