Move trust current Wi-Fi to function

This commit is contained in:
Davide De Rosa 2019-10-20 23:55:05 +02:00
parent f75d9ced91
commit 802a4a4586
1 changed files with 19 additions and 14 deletions

View File

@ -338,6 +338,24 @@ class ServiceViewController: UIViewController, StrongTableHost {
}
}
private func trustCurrentWiFi() -> Bool {
if #available(iOS 12, *) {
IntentDispatcher.donateTrustCurrentNetwork()
IntentDispatcher.donateUntrustCurrentNetwork()
}
guard trustedNetworks.addCurrentWifi() else {
let alert = UIAlertController.asAlert(
L10n.Core.Service.Sections.Trusted.header,
L10n.Core.Service.Alerts.Trusted.NoNetwork.message
)
alert.addCancelAction(L10n.Core.Global.ok)
present(alert, animated: true, completion: nil)
return false
}
return true
}
private func toggleTrustedConnectionPolicy(_ isOn: Bool, sender: ToggleTableViewCell) {
let completionHandler: () -> Void = {
self.service.preferences.trustPolicy = isOn ? .disconnect : .ignore
@ -931,20 +949,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
return true
case .trustedAddCurrentWiFi:
if #available(iOS 12, *) {
IntentDispatcher.donateTrustCurrentNetwork()
IntentDispatcher.donateUntrustCurrentNetwork()
}
guard trustedNetworks.addCurrentWifi() else {
let alert = UIAlertController.asAlert(
L10n.Core.Service.Sections.Trusted.header,
L10n.Core.Service.Alerts.Trusted.NoNetwork.message
)
alert.addCancelAction(L10n.Core.Global.ok)
present(alert, animated: true, completion: nil)
return false
}
return trustCurrentWiFi()
case .testConnectivity:
testInternetConnectivity()