@@ -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
@@ -54,10 +54,16 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
54
54
}
55
55
56
56
func start( ) {
57
+ let startContext : LocationViewControllerWrapper . MultihopContext =
58
+ if case . noRelaysSatisfyingDaitaConstraints = tunnelManager. tunnelStatus. observedState
59
+ . blockedState? . reason { . entry } else { . exit }
60
+
57
61
let locationViewControllerWrapper = LocationViewControllerWrapper (
58
62
customListRepository: customListRepository,
59
63
constraints: tunnelManager. settings. relayConstraints,
60
- multihopEnabled: tunnelManager. settings. tunnelMultihopState. isEnabled
64
+ multihopEnabled: tunnelManager. settings. tunnelMultihopState. isEnabled,
65
+ daitaEnabled: tunnelManager. settings. daita. state. isEnabled,
66
+ startContext: startContext
61
67
)
62
68
locationViewControllerWrapper. delegate = self
63
69
@@ -69,8 +75,13 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
69
75
relayCacheTracker. addObserver ( self )
70
76
71
77
if let cachedRelays = try ? relayCacheTracker. getCachedRelays ( ) {
72
- self . cachedRelays = cachedRelays
73
- locationViewControllerWrapper. setCachedRelays ( cachedRelays, filter: relayFilter)
78
+ let locationRelays = LocationRelays (
79
+ relays: cachedRelays. relays. wireguard. relays,
80
+ locations: cachedRelays. relays. locations
81
+ )
82
+ self . cachedRelays = locationRelays
83
+
84
+ locationViewControllerWrapper. setCachedRelays ( locationRelays, filter: relayFilter)
74
85
}
75
86
76
87
navigationController. pushViewController ( locationViewControllerWrapper, animated: false )
@@ -87,7 +98,11 @@ class LocationCoordinator: Coordinator, Presentable, Presenting {
87
98
)
88
99
89
100
relayFilterCoordinator. didFinish = { [ weak self] coordinator, filter in
90
- if let cachedRelays = self ? . cachedRelays, let filter {
101
+ if var cachedRelays = self ? . cachedRelays, let filter {
102
+ cachedRelays. relays = cachedRelays. relays. filter { relay in
103
+ RelaySelector . relayMatchesFilter ( relay, filter: filter)
104
+ }
105
+
91
106
self ? . locationViewControllerWrapper? . setCachedRelays ( cachedRelays, filter: filter)
92
107
}
93
108
@@ -148,9 +163,13 @@ extension LocationCoordinator: RelayCacheTrackerObserver {
148
163
_ tracker: RelayCacheTracker ,
149
164
didUpdateCachedRelays cachedRelays: CachedRelays
150
165
) {
151
- self . cachedRelays = cachedRelays
166
+ let locationRelays = LocationRelays (
167
+ relays: cachedRelays. relays. wireguard. relays,
168
+ locations: cachedRelays. relays. locations
169
+ )
170
+ self . cachedRelays = locationRelays
152
171
153
- locationViewControllerWrapper? . setCachedRelays ( cachedRelays , filter: relayFilter)
172
+ locationViewControllerWrapper? . setCachedRelays ( locationRelays , filter: relayFilter)
154
173
}
155
174
}
156
175
@@ -178,6 +197,10 @@ extension LocationCoordinator: LocationViewControllerWrapperDelegate {
178
197
relayConstraints. filter = . only( filter)
179
198
180
199
tunnelManager. updateSettings ( [ . relayConstraints( relayConstraints) ] )
200
+
201
+ if let cachedRelays {
202
+ locationViewControllerWrapper? . setCachedRelays ( cachedRelays, filter: filter)
203
+ }
181
204
}
182
205
183
206
func navigateToFilter( ) {
0 commit comments