Skip to content

Commit

Permalink
Fix multiple Wireguard port selection in settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
rablador committed Dec 3, 2024
1 parent 8bda210 commit 6afd27f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<
weak var delegate: VPNSettingsDataSourceDelegate?

var selectedIndexPaths: [IndexPath] {
let wireGuardPortItem: Item = viewModel.customWireGuardPort == nil
? .wireGuardPort(viewModel.wireGuardPort)
: .wireGuardCustomPort
var wireGuardPortItem: Item = .wireGuardPort(viewModel.wireGuardPort)
if let customPort = indexPath(for: .wireGuardCustomPort) {
if tableView?.indexPathsForSelectedRows?.contains(customPort) ?? false {
wireGuardPortItem = .wireGuardCustomPort
}
}

let obfuscationStateItem: Item = switch viewModel.obfuscationState {
case .automatic: .wireGuardObfuscationAutomatic
Expand Down Expand Up @@ -253,6 +256,9 @@ final class VPNSettingsDataSource: UITableViewDiffableDataSource<

Item.wireGuardPorts.forEach { item in
if case let .wireGuardPort(port) = item, port == viewModel.wireGuardPort {
if let indexPath = indexPath(for: item) {
deselectAllRowsInSectionExceptRowAt(indexPath)
}
selectRow(at: item)
return
}
Expand Down

0 comments on commit 6afd27f

Please sign in to comment.