From ccfcf90e395f5ee434a2c6e881bde312d2f7c0c0 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 6e33890235db..6127ee10e17f 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/VPNSettingsDataSource.swift @@ -189,9 +189,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 @@ -256,6 +259,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 }