Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where location list is empty on release build #5902

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix bug where location list is empty on release build
  • Loading branch information
Jon Petersson committed Mar 5, 2024
commit e5569a98940a3d8327b6c782fff0dbfda2bbdf51
Original file line number Diff line number Diff line change
@@ -51,28 +51,28 @@ final class LocationDataSource: UITableViewDiffableDataSource<LocationSection, L
}

func setRelays(_ response: REST.ServerRelaysResponse, selectedLocations: RelayLocations?, filter: RelayFilter) {
guard let customListsDataSource =
dataSources.first(where: { $0 is CustomListsDataSource }) as? CustomListsDataSource,
let allLocationsDataSource =
let allLocationsDataSource =
dataSources.first(where: { $0 is AllLocationDataSource }) as? AllLocationDataSource
else { return }

let customListsDataSource =
dataSources.first(where: { $0 is CustomListsDataSource }) as? CustomListsDataSource

let relays = response.wireguard.relays.filter { relay in
RelaySelector.relayMatchesFilter(relay, filter: filter)
}

allLocationsDataSource.reload(response, relays: relays)
customListsDataSource.reload(allLocationNodes: allLocationsDataSource.nodes)
allLocationsDataSource?.reload(response, relays: relays)
customListsDataSource?.reload(allLocationNodes: allLocationsDataSource?.nodes ?? [])

if let selectedLocations {
// Look for a matching custom list node.
if let customListId = selectedLocations.customListId,
let customList = customListsDataSource.customList(by: customListId),
let selectedNode = customListsDataSource.node(by: selectedLocations.locations, for: customList) {
let customList = customListsDataSource?.customList(by: customListId),
let selectedNode = customListsDataSource?.node(by: selectedLocations.locations, for: customList) {
selectedItem = LocationCellViewModel(section: .customLists, node: selectedNode)
// Look for a matching all locations node.
} else if let location = selectedLocations.locations.first,
let selectedNode = allLocationsDataSource.node(by: location) {
let selectedNode = allLocationsDataSource?.node(by: location) {
selectedItem = LocationCellViewModel(section: .allLocations, node: selectedNode)
}
}
Loading
Oops, something went wrong.