From 6afd27f10d23ca2ab0e2b6679adb1578a86ca11e Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Fri, 29 Nov 2024 10:10:59 +0100 Subject: [PATCH] Fix multiple Wireguard port selection in settings view --- .../VPNSettings/VPNSettingsDataSource.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift index 0855d204b401..6f5f59a240da 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift @@ -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 @@ -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 }