Skip to content

Commit

Permalink
Fix filter apply button being enabled with zero providers
Browse files Browse the repository at this point in the history
  • Loading branch information
rablador committed Nov 11, 2024
1 parent a8d5fc0 commit 8cb08ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8cb08ef

Please sign in to comment.