Skip to content

Commit 4d12a45

Browse files
Jon Peterssonbuggmagnet
Jon Petersson
authored andcommitted
Fix LocationDataSource crash in MockRelease build
1 parent 624d37a commit 4d12a45

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift

+13-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ final class LocationDataSource: UITableViewDiffableDataSource<SelectLocationSect
2626
customLists: LocationDataSourceProtocol
2727
) {
2828
self.tableView = tableView
29+
30+
#if DEBUG
2931
self.dataSources.append(customLists)
32+
#endif
3033
self.dataSources.append(allLocations)
3134

3235
let locationCellFactory = LocationCellFactory(
@@ -76,14 +79,16 @@ final class LocationDataSource: UITableViewDiffableDataSource<SelectLocationSect
7679
.map { LocationCellViewModel(group: group, location: $0) }
7780
}
7881

79-
updateDataSnapshot(with: list, reloadExisting: !searchString.isEmpty)
80-
81-
if searchString.isEmpty {
82-
setSelectedRelayLocation(selectedRelayLocation, animated: false, completion: {
83-
self.scrollToSelectedRelay()
84-
})
85-
} else {
86-
scrollToTop(animated: false)
82+
updateDataSnapshot(with: list, reloadExisting: !searchString.isEmpty) {
83+
DispatchQueue.main.async {
84+
if searchString.isEmpty {
85+
self.setSelectedRelayLocation(self.selectedRelayLocation, animated: false, completion: {
86+
self.scrollToSelectedRelay()
87+
})
88+
} else {
89+
self.scrollToTop(animated: false)
90+
}
91+
}
8792
}
8893
}
8994

0 commit comments

Comments
 (0)