Commit network settings in separate method
This commit is contained in:
parent
ab189025b9
commit
b45479a733
|
@ -53,10 +53,10 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
|
|
||||||
private lazy var networkChoices = ProfileNetworkChoices.with(profile: profile)
|
private lazy var networkChoices = ProfileNetworkChoices.with(profile: profile)
|
||||||
|
|
||||||
private let networkSettings = ProfileNetworkSettings()
|
|
||||||
|
|
||||||
private lazy var clientNetworkSettings = profile?.clientNetworkSettings
|
private lazy var clientNetworkSettings = profile?.clientNetworkSettings
|
||||||
|
|
||||||
|
private let networkSettings = ProfileNetworkSettings()
|
||||||
|
|
||||||
// MARK: TableModelHost
|
// MARK: TableModelHost
|
||||||
|
|
||||||
let model: TableModel<SectionType, RowType> = TableModel()
|
let model: TableModel<SectionType, RowType> = TableModel()
|
||||||
|
@ -124,23 +124,8 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
|
|
||||||
override func viewDidDisappear(_ animated: Bool) {
|
override func viewDidDisappear(_ animated: Bool) {
|
||||||
super.viewDidDisappear(animated)
|
super.viewDidDisappear(animated)
|
||||||
|
|
||||||
profile?.networkChoices = networkChoices
|
commitChanges()
|
||||||
if networkChoices.gateway == .manual {
|
|
||||||
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
|
||||||
settings.copyGateway(from: networkSettings)
|
|
||||||
profile?.manualNetworkSettings = settings
|
|
||||||
}
|
|
||||||
if networkChoices.dns == .manual {
|
|
||||||
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
|
||||||
settings.copyDNS(from: networkSettings)
|
|
||||||
profile?.manualNetworkSettings = settings
|
|
||||||
}
|
|
||||||
if networkChoices.proxy == .manual {
|
|
||||||
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
|
||||||
settings.copyProxy(from: networkSettings)
|
|
||||||
profile?.manualNetworkSettings = settings
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
@ -220,6 +205,25 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
|
|
||||||
log.debug("Network settings: \(networkSettings)")
|
log.debug("Network settings: \(networkSettings)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func commitChanges() {
|
||||||
|
profile?.networkChoices = networkChoices
|
||||||
|
if networkChoices.gateway == .manual {
|
||||||
|
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
||||||
|
settings.copyGateway(from: networkSettings)
|
||||||
|
profile?.manualNetworkSettings = settings
|
||||||
|
}
|
||||||
|
if networkChoices.dns == .manual {
|
||||||
|
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
||||||
|
settings.copyDNS(from: networkSettings)
|
||||||
|
profile?.manualNetworkSettings = settings
|
||||||
|
}
|
||||||
|
if networkChoices.proxy == .manual {
|
||||||
|
let settings = profile?.manualNetworkSettings ?? ProfileNetworkSettings()
|
||||||
|
settings.copyProxy(from: networkSettings)
|
||||||
|
profile?.manualNetworkSettings = settings
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
Loading…
Reference in New Issue