On-Demand: TunnelViewModel: Make activate-on-demand methods static
This commit is contained in:
parent
4f98330bc0
commit
3af543a352
|
@ -451,7 +451,7 @@ class TunnelViewModel {
|
||||||
// MARK: Activate on demand
|
// MARK: Activate on demand
|
||||||
|
|
||||||
extension TunnelViewModel {
|
extension TunnelViewModel {
|
||||||
func activateOnDemandOptionText(for activateOnDemandOption: ActivateOnDemandOption) -> String {
|
static func activateOnDemandOptionText(for activateOnDemandOption: ActivateOnDemandOption) -> String {
|
||||||
switch (activateOnDemandOption) {
|
switch (activateOnDemandOption) {
|
||||||
case .none:
|
case .none:
|
||||||
return "Off"
|
return "Off"
|
||||||
|
@ -476,7 +476,7 @@ extension TunnelViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
static func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
||||||
return .useOnDemandOverWiFiOrCellular
|
return .useOnDemandOverWiFiOrCellular
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -389,7 +389,7 @@ extension TunnelEditTableViewController {
|
||||||
if (isOn) {
|
if (isOn) {
|
||||||
s.activateOnDemandSetting.isActivateOnDemandEnabled = true
|
s.activateOnDemandSetting.isActivateOnDemandEnabled = true
|
||||||
if (s.activateOnDemandSetting.activateOnDemandOption == .none) {
|
if (s.activateOnDemandSetting.activateOnDemandOption == .none) {
|
||||||
s.activateOnDemandSetting.activateOnDemandOption = s.tunnelViewModel.defaultActivateOnDemandOption()
|
s.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption()
|
||||||
}
|
}
|
||||||
s.tableView.insertRows(at: indexPaths, with: .automatic)
|
s.tableView.insertRows(at: indexPaths, with: .automatic)
|
||||||
} else {
|
} else {
|
||||||
|
@ -404,7 +404,7 @@ extension TunnelEditTableViewController {
|
||||||
let rowOption = activateOnDemandOptions[row - 1]
|
let rowOption = activateOnDemandOptions[row - 1]
|
||||||
let selectedOption = activateOnDemandSetting.activateOnDemandOption
|
let selectedOption = activateOnDemandSetting.activateOnDemandOption
|
||||||
assert(selectedOption != .none)
|
assert(selectedOption != .none)
|
||||||
cell.message = tunnelViewModel.activateOnDemandOptionText(for: rowOption)
|
cell.message = TunnelViewModel.activateOnDemandOptionText(for: rowOption)
|
||||||
cell.isChecked = (selectedOption == rowOption)
|
cell.isChecked = (selectedOption == rowOption)
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue