diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift index 3ee5e3245250..ee5efa3d2497 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationDataSource.swift @@ -75,14 +75,11 @@ final class LocationDataSource: UITableViewDiffableDataSource Node { + let node: Node + + switch ascendantOrSelf { + case .country: + node = Node( + type: .country, + location: ascendantOrSelf, + displayName: serverLocation.country, + showsChildren: wasShowingChildren, + isActive: true, + children: [] + ) + rootNode.addChild(node) + + case let .city(countryCode, _): + node = Node( + type: .city, + location: ascendantOrSelf, + displayName: serverLocation.city, + showsChildren: wasShowingChildren, + isActive: true, + children: [] + ) + nodeByLocation[.country(countryCode)]!.addChild(node) + + case let .hostname(countryCode, cityCode, _): + node = Node( + type: .relay, + location: ascendantOrSelf, + displayName: relay.hostname, + showsChildren: false, + isActive: relay.active, + children: [] + ) + nodeByLocation[.city(countryCode, cityCode)]!.addChild(node) + } + + return node + } + private func updateDataSnapshot( with locations: [RelayLocation], reloadExisting: Bool = false,