Skip to content

Commit

Permalink
Update logic for showing DAITA filter pill
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson committed Oct 8, 2024
1 parent 84e0c9c commit 9fd359e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Coordinators/LocationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
customListRepository: customListRepository,
constraints: tunnelManager.settings.relayConstraints,
multihopEnabled: tunnelManager.settings.tunnelMultihopState.isEnabled,
daitaEnabled: tunnelManager.settings.daita.daitaState.isEnabled,
daitaSettings: tunnelManager.settings.daita,
startContext: startContext
)
locationViewControllerWrapper.delegate = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class LocationViewController: UIViewController {
private var relaysWithLocation: LocationRelays?
private var filter = RelayFilter()
private var selectedRelays: RelaySelection
private var daitaEnabled: Bool
private var shouldFilterDaita: Bool
weak var delegate: LocationViewControllerDelegate?
var customListRepository: CustomListRepositoryProtocol

Expand All @@ -35,17 +35,17 @@ final class LocationViewController: UIViewController {
}

var filterViewShouldBeHidden: Bool {
!daitaEnabled && (filter.ownership == .any) && (filter.providers == .any)
!shouldFilterDaita && (filter.ownership == .any) && (filter.providers == .any)
}

init(
customListRepository: CustomListRepositoryProtocol,
selectedRelays: RelaySelection,
daitaEnabled: Bool = false
shouldFilterDaita: Bool
) {
self.customListRepository = customListRepository
self.selectedRelays = selectedRelays
self.daitaEnabled = daitaEnabled
self.shouldFilterDaita = shouldFilterDaita

super.init(nibName: nil, bundle: nil)
}
Expand Down Expand Up @@ -154,7 +154,7 @@ final class LocationViewController: UIViewController {
topContentView.addArrangedSubview(searchBar)

filterView.isHidden = filterViewShouldBeHidden
filterView.setDaita(daitaEnabled)
filterView.setDaita(shouldFilterDaita)

filterView.didUpdateFilter = { [weak self] in
self?.delegate?.didUpdateFilter(filter: $0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ final class LocationViewControllerWrapper: UIViewController {
private var selectedExit: UserSelectedRelays?
private let multihopEnabled: Bool
private var multihopContext: MultihopContext = .exit
private let daitaEnabled: Bool
private let daitaSettings: DAITASettings

weak var delegate: LocationViewControllerWrapperDelegate?

init(
customListRepository: CustomListRepositoryProtocol,
constraints: RelayConstraints,
multihopEnabled: Bool,
daitaEnabled: Bool,
daitaSettings: DAITASettings,
startContext: MultihopContext
) {
self.multihopEnabled = multihopEnabled
self.daitaEnabled = daitaEnabled
self.daitaSettings = daitaSettings
multihopContext = startContext

selectedEntry = constraints.entryLocations.value
Expand All @@ -73,13 +73,16 @@ final class LocationViewControllerWrapper: UIViewController {
entryLocationViewController = LocationViewController(
customListRepository: customListRepository,
selectedRelays: RelaySelection(),
daitaEnabled: multihopEnabled && daitaEnabled
shouldFilterDaita: daitaSettings.daitaState.isEnabled
&& daitaSettings.directOnlyState.isEnabled
)

exitLocationViewController = LocationViewController(
customListRepository: customListRepository,
selectedRelays: RelaySelection(),
daitaEnabled: !multihopEnabled && daitaEnabled
shouldFilterDaita: !multihopEnabled
&& daitaSettings.daitaState.isEnabled
&& daitaSettings.directOnlyState.isEnabled
)

super.init(nibName: nil, bundle: nil)
Expand Down Expand Up @@ -109,7 +112,7 @@ final class LocationViewControllerWrapper: UIViewController {

func setRelaysWithLocation(_ relaysWithLocation: LocationRelays, filter: RelayFilter) {
var daitaFilteredRelays = relaysWithLocation
if daitaEnabled {
if daitaSettings.daitaState.isEnabled && daitaSettings.directOnlyState.isEnabled {
daitaFilteredRelays.relays = relaysWithLocation.relays.filter { relay in
relay.daita == true
}
Expand Down

0 comments on commit 9fd359e

Please sign in to comment.