Skip to content

Commit 2131b2c

Browse files
author
Jon Petersson
committed
Fix selection of custom list location not being retained
1 parent 4b4304f commit 2131b2c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,21 @@ class CustomListsDataSource: LocationDataSourceProtocol {
8585
return switch location {
8686
case let .country(countryCode):
8787
rootNode
88-
.countryFor(code: countryCode)?.copy(withParent: parentNode)
88+
.countryFor(code: countryCode)?
89+
.copy(withParent: parentNode)
8990

9091
case let .city(countryCode, cityCode):
9192
rootNode
92-
.countryFor(code: countryCode)?.copy(withParent: parentNode)
93-
.cityFor(codes: [countryCode, cityCode])
93+
.countryFor(code: countryCode)?
94+
.cityFor(codes: [countryCode, cityCode])?
95+
.copy(withParent: parentNode)
9496

9597
case let .hostname(countryCode, cityCode, hostCode):
9698
rootNode
97-
.countryFor(code: countryCode)?.copy(withParent: parentNode)
99+
.countryFor(code: countryCode)?
98100
.cityFor(codes: [countryCode, cityCode])?
99-
.hostFor(code: hostCode)
101+
.hostFor(code: hostCode)?
102+
.copy(withParent: parentNode)
100103
}
101104
}
102105
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extension LocationNode {
8080
}
8181

8282
extension LocationNode {
83+
/// Recursively copies a node, its parent and its descendants from another
84+
/// node (tree), with an optional custom root parent.
8385
func copy(withParent parent: LocationNode? = nil) -> LocationNode {
8486
let node = LocationNode(
8587
name: name,

0 commit comments

Comments
 (0)