@@ -16,7 +16,7 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
16
16
private let tunnelManager : TunnelManager
17
17
private let relayCacheTracker : RelayCacheTracker
18
18
private let customListRepository : CustomListRepositoryProtocol
19
- private var cachedRelays : CachedRelays ?
19
+ private var cachedRelays : LocationRelays ?
20
20
21
21
let navigationController : UINavigationController
22
22
@@ -69,8 +69,13 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
69
69
relayCacheTracker. addObserver ( self )
70
70
71
71
if let cachedRelays = try ? relayCacheTracker. getCachedRelays ( ) {
72
- self . cachedRelays = cachedRelays
73
- locationViewControllerWrapper. setCachedRelays ( cachedRelays, filter: relayFilter)
72
+ let locationRelays = LocationRelays (
73
+ relays: cachedRelays. relays. wireguard. relays,
74
+ locations: cachedRelays. relays. locations
75
+ )
76
+ self . cachedRelays = locationRelays
77
+
78
+ locationViewControllerWrapper. setCachedRelays ( locationRelays, filter: relayFilter)
74
79
}
75
80
76
81
navigationController. pushViewController ( locationViewControllerWrapper, animated: false )
@@ -87,7 +92,11 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
87
92
)
88
93
89
94
relayFilterCoordinator. didFinish = { [ weak self] coordinator, filter in
90
- if let cachedRelays = self ? . cachedRelays, let filter {
95
+ if var cachedRelays = self ? . cachedRelays, let filter {
96
+ cachedRelays. relays = cachedRelays. relays. filter { relay in
97
+ RelaySelector . relayMatchesFilter ( relay, filter: filter)
98
+ }
99
+
91
100
self ? . locationViewControllerWrapper? . setCachedRelays ( cachedRelays, filter: filter)
92
101
}
93
102
@@ -148,9 +157,13 @@ extension LocationCoordinator: RelayCacheTrackerObserver {
148
157
_ tracker: RelayCacheTracker ,
149
158
didUpdateCachedRelays cachedRelays: CachedRelays
150
159
) {
151
- self . cachedRelays = cachedRelays
160
+ let locationRelays = LocationRelays (
161
+ relays: cachedRelays. relays. wireguard. relays,
162
+ locations: cachedRelays. relays. locations
163
+ )
164
+ self . cachedRelays = locationRelays
152
165
153
- locationViewControllerWrapper? . setCachedRelays ( cachedRelays , filter: relayFilter)
166
+ locationViewControllerWrapper? . setCachedRelays ( locationRelays , filter: relayFilter)
154
167
}
155
168
}
156
169
@@ -178,6 +191,10 @@ extension LocationCoordinator: LocationViewControllerWrapperDelegate {
178
191
relayConstraints. filter = . only( filter)
179
192
180
193
tunnelManager. updateSettings ( [ . relayConstraints( relayConstraints) ] )
194
+
195
+ if let cachedRelays {
196
+ locationViewControllerWrapper? . setCachedRelays ( cachedRelays, filter: filter)
197
+ }
181
198
}
182
199
183
200
func navigateToFilter( ) {
0 commit comments