Move trust actions to separate functions
This commit is contained in:
parent
302e281399
commit
1d7cdc7f19
|
@ -346,6 +346,15 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
|||
}
|
||||
}
|
||||
|
||||
private func trustMobileNetwork(cell: ToggleTableViewCell) {
|
||||
if #available(iOS 12, *) {
|
||||
IntentDispatcher.donateTrustCellularNetwork()
|
||||
IntentDispatcher.donateUntrustCellularNetwork()
|
||||
}
|
||||
|
||||
trustedNetworks.setMobile(cell.isOn)
|
||||
}
|
||||
|
||||
private func trustCurrentWiFi() {
|
||||
if #available(iOS 13, *) {
|
||||
let auth = CLLocationManager.authorizationStatus()
|
||||
|
@ -390,6 +399,14 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
|||
}
|
||||
}
|
||||
|
||||
private func toggleTrustWiFi(cell: ToggleTableViewCell, at row: Int) {
|
||||
if cell.isOn {
|
||||
trustedNetworks.enableWifi(at: row)
|
||||
} else {
|
||||
trustedNetworks.disableWifi(at: row)
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleTrustedConnectionPolicy(_ isOn: Bool, sender: ToggleTableViewCell) {
|
||||
let completionHandler: () -> Void = {
|
||||
self.service.preferences.trustPolicy = isOn ? .disconnect : .ignore
|
||||
|
@ -1071,22 +1088,13 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
|||
toggleDisconnectsOnSleep(cell.isOn)
|
||||
|
||||
case .trustedMobile:
|
||||
if #available(iOS 12, *) {
|
||||
IntentDispatcher.donateTrustCellularNetwork()
|
||||
IntentDispatcher.donateUntrustCellularNetwork()
|
||||
}
|
||||
|
||||
trustedNetworks.setMobile(cell.isOn)
|
||||
trustMobileNetwork(cell: cell)
|
||||
|
||||
case .trustedWiFi:
|
||||
guard let indexPath = tableView.indexPath(for: cell) else {
|
||||
return
|
||||
}
|
||||
if cell.isOn {
|
||||
trustedNetworks.enableWifi(at: indexPath.row)
|
||||
} else {
|
||||
trustedNetworks.disableWifi(at: indexPath.row)
|
||||
}
|
||||
toggleTrustWiFi(cell: cell, at: indexPath.row)
|
||||
|
||||
case .trustedPolicy:
|
||||
toggleTrustedConnectionPolicy(cell.isOn, sender: cell)
|
||||
|
|
Loading…
Reference in New Issue