From 8cb08efcc0e3dea9291bb250e8df335b2df37f47 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Mon, 11 Nov 2024 16:51:07 +0100 Subject: [PATCH] Fix filter apply button being enabled with zero providers --- .../RelayFilter/RelayFilterDataSource.swift | 4 ---- .../RelayFilter/RelayFilterViewController.swift | 13 ++++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterDataSource.swift b/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterDataSource.swift index 3b4fadeac9b6..ad36ef12f29f 100644 --- a/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterDataSource.swift +++ b/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterDataSource.swift @@ -285,10 +285,6 @@ extension RelayFilterDataSource: UITableViewDelegate { return nil } - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return UITableView.automaticDimension - } - func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return UIMetrics.TableView.separatorHeight } diff --git a/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterViewController.swift b/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterViewController.swift index 046e466a802d..8f20982659b3 100644 --- a/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterViewController.swift +++ b/ios/MullvadVPN/View controllers/RelayFilter/RelayFilterViewController.swift @@ -96,7 +96,18 @@ class RelayFilterViewController: UIViewController { case .any: self?.applyButton.isEnabled = true case let .only(providers): - self?.applyButton.isEnabled = !providers.isEmpty + switch filter.ownership { + case .any: + self?.applyButton.isEnabled = !providers.isEmpty + case .owned: + let filterHasAtLeastOneOwnedProvider = viewModel.ownedProviders + .first(where: { providers.contains($0) }) != nil + self?.applyButton.isEnabled = filterHasAtLeastOneOwnedProvider + case .rented: + let filterHasAtLeastOneRentedProvider = viewModel.rentedProviders + .first(where: { providers.contains($0) }) != nil + self?.applyButton.isEnabled = filterHasAtLeastOneRentedProvider + } } } .store(in: &disposeBag)