Switch to a custom HomeserverReachability instead of different publishers

This commit is contained in:
Stefan Ceriu
2026-06-24 19:14:27 +03:00
parent 3ccaa04554
commit 0bd32d24fd
15 changed files with 65 additions and 50 deletions
@@ -275,7 +275,7 @@ class AuthenticationFlowCoordinator: FlowCoordinatorProtocol {
let mediaProvider = authenticationService.classicAppAccount.map { account in
MediaProvider(mediaLoader: ClassicAppMediaLoader(classicAppAccount: account),
imageCache: .onlyInMemory,
homeserverReachabilityPublisher: appMediator.networkMonitor.reachabilityPublisher) // Close enough approximation
homeserverReachabilityPublisher: appMediator.networkMonitor.reachabilityPublisher.map(HomeserverReachability.init)) // Close enough approximation
}
let parameters = AuthenticationStartScreenParameters(authenticationService: authenticationService,
@@ -285,7 +285,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
.store(in: &cancellables)
let reachabilityNotificationID = "io.element.elementx.reachability.notification"
userSession.clientProxy.homeserverConnectivityPublisher.removeDuplicates()
userSession.clientProxy.homeserverReachabilityPublisher.removeDuplicates()
.combineLatest(flowParameters.appMediator.networkMonitor.reachabilityPublisher.removeDuplicates())
.receive(on: DispatchQueue.main)
.sink { [weak self] homeserverReachability, networkReachability in
@@ -293,16 +293,17 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
guard let self else { return }
switch (networkReachability, homeserverReachability) {
case (.reachable, .reachable):
flowParameters.userIndicatorController.retractIndicatorWithId(reachabilityNotificationID)
case (.reachable, .unreachable):
flowParameters.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationID,
title: L10n.commonServerUnreachable,
persistent: true))
case (.unreachable, _):
flowParameters.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationID,
title: L10n.commonOffline,
persistent: true))
case (.reachable, .unreachable):
flowParameters.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationID,
title: L10n.commonServerUnreachable,
persistent: true))
// Don't alarm the user while we've intentionally suspended the client.
case (.reachable, .reachable), (.reachable, .suspended):
flowParameters.userIndicatorController.retractIndicatorWithId(reachabilityNotificationID)
}
}
.store(in: &cancellables)