From 3af543a35299a12e2593c51d4dba088b53d4fd74 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sat, 8 Dec 2018 00:54:58 +0530 Subject: [PATCH] On-Demand: TunnelViewModel: Make activate-on-demand methods static --- WireGuard/WireGuard/UI/TunnelViewModel.swift | 4 ++-- .../WireGuard/UI/iOS/TunnelEditTableViewController.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index 2a3f36b..de14ad5 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -451,7 +451,7 @@ class TunnelViewModel { // MARK: Activate on demand extension TunnelViewModel { - func activateOnDemandOptionText(for activateOnDemandOption: ActivateOnDemandOption) -> String { + static func activateOnDemandOptionText(for activateOnDemandOption: ActivateOnDemandOption) -> String { switch (activateOnDemandOption) { case .none: return "Off" @@ -476,7 +476,7 @@ extension TunnelViewModel { } } - func defaultActivateOnDemandOption() -> ActivateOnDemandOption { + static func defaultActivateOnDemandOption() -> ActivateOnDemandOption { return .useOnDemandOverWiFiOrCellular } diff --git a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift index c110d73..6b737fe 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelEditTableViewController.swift @@ -389,7 +389,7 @@ extension TunnelEditTableViewController { if (isOn) { s.activateOnDemandSetting.isActivateOnDemandEnabled = true if (s.activateOnDemandSetting.activateOnDemandOption == .none) { - s.activateOnDemandSetting.activateOnDemandOption = s.tunnelViewModel.defaultActivateOnDemandOption() + s.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption() } s.tableView.insertRows(at: indexPaths, with: .automatic) } else { @@ -404,7 +404,7 @@ extension TunnelEditTableViewController { let rowOption = activateOnDemandOptions[row - 1] let selectedOption = activateOnDemandSetting.activateOnDemandOption assert(selectedOption != .none) - cell.message = tunnelViewModel.activateOnDemandOptionText(for: rowOption) + cell.message = TunnelViewModel.activateOnDemandOptionText(for: rowOption) cell.isChecked = (selectedOption == rowOption) return cell }