}
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)
+ }
}
}
self.tunnelsManager = tunnelsManager
self.tunnel = tunnel
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
- onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
super.init(style: .grouped)
loadSections()
loadVisibleFields()
}
onDemandObservationToken = tunnel.observe(\.isActivateOnDemandEnabled) { [weak self] tunnel, _ in
// Handle On-Demand getting turned on/off outside of the app
- self?.onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ self?.onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
self?.updateActivateOnDemandFields()
}
}
extension TunnelDetailTableViewController: TunnelEditTableViewControllerDelegate {
func tunnelSaved(tunnel: TunnelContainer) {
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
- onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
loadSections()
loadVisibleFields()
title = tunnel.name
self.tunnelsManager = tunnelsManager
self.tunnel = tunnel
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
- onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
super.init(style: .grouped)
loadSections()
}
self.tunnelsManager = tunnelsManager
self.tunnel = tunnel
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
- onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
super.init(nibName: nil, bundle: nil)
updateTableViewModelRowsBySection()
updateTableViewModelRows()
extension TunnelDetailTableViewController: TunnelEditViewControllerDelegate {
func tunnelSaved(tunnel: TunnelContainer) {
tunnelViewModel = TunnelViewModel(tunnelConfiguration: tunnel.tunnelConfiguration)
- onDemandViewModel = ActivateOnDemandViewModel(option: tunnel.onDemandOption)
+ onDemandViewModel = ActivateOnDemandViewModel(tunnel: tunnel)
updateTableViewModelRowsBySection()
updateTableViewModelRows()
updateStatus()
init(tunnelsManager: TunnelsManager, tunnel: TunnelContainer?) {
self.tunnelsManager = tunnelsManager
self.tunnel = tunnel
- self.onDemandViewModel = tunnel != nil ? ActivateOnDemandViewModel(option: tunnel!.onDemandOption) : ActivateOnDemandViewModel()
+ self.onDemandViewModel = tunnel != nil ? ActivateOnDemandViewModel(tunnel: tunnel!) : ActivateOnDemandViewModel()
super.init(nibName: nil, bundle: nil)
}