Skip to content

Commit

Permalink
Fix VPN settings not being persisted
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson authored and pinkisemils committed Sep 10, 2024
1 parent ebfbdcc commit 90135e4
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
private let vpnSettingsCellFactory: VPNSettingsCellFactory
private weak var tableView: UITableView?

private var obfuscationSettings: WireGuardObfuscationSettings {
WireGuardObfuscationSettings(
state: viewModel.obfuscationState,
port: viewModel.obfuscationPort
)
}

weak var delegate: VPNSettingsDataSourceDelegate?

var selectedIndexPaths: [IndexPath] {
Expand Down Expand Up @@ -261,12 +268,6 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<

deselectAllRowsInSectionExceptRowAt(indexPath)

let obfuscationSettingsUpdate = TunnelSettingsUpdate.obfuscation(WireGuardObfuscationSettings(
state: viewModel.obfuscationState,
port: viewModel.obfuscationPort
))
let quantumResistanceUpdate = TunnelSettingsUpdate.quantumResistance(viewModel.quantumResistance)

switch item {
case .dnsSettings:
tableView.deselectRow(at: indexPath, animated: false)
Expand All @@ -291,25 +292,25 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<

case .wireGuardObfuscationAutomatic:
selectObfuscationState(.automatic)
delegate?.didUpdateTunnelSettings(obfuscationSettingsUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.obfuscation(obfuscationSettings))
case .wireGuardObfuscationOn:
selectObfuscationState(.on)
delegate?.didUpdateTunnelSettings(obfuscationSettingsUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.obfuscation(obfuscationSettings))
case .wireGuardObfuscationOff:
selectObfuscationState(.off)
delegate?.didUpdateTunnelSettings(obfuscationSettingsUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.obfuscation(obfuscationSettings))
case let .wireGuardObfuscationPort(port):
selectObfuscationPort(port)
delegate?.didUpdateTunnelSettings(obfuscationSettingsUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.obfuscation(obfuscationSettings))
case .quantumResistanceAutomatic:
selectQuantumResistance(.automatic)
delegate?.didUpdateTunnelSettings(quantumResistanceUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.quantumResistance(viewModel.quantumResistance))
case .quantumResistanceOn:
selectQuantumResistance(.on)
delegate?.didUpdateTunnelSettings(quantumResistanceUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.quantumResistance(viewModel.quantumResistance))
case .quantumResistanceOff:
selectQuantumResistance(.off)
delegate?.didUpdateTunnelSettings(quantumResistanceUpdate)
delegate?.didUpdateTunnelSettings(TunnelSettingsUpdate.quantumResistance(viewModel.quantumResistance))
default:
break
}
Expand Down

0 comments on commit 90135e4

Please sign in to comment.