mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Use the SDK's offline detection everywhere (except for restarting the sync loop). (#4472)
* Use the SDK's offline state to drive the offline indicator. * Only use network reachability for restarting the sync loop, use the homeserver reachability for requests. * Add a separate indicator to distinguish when the server is unreachable but the device is online.
This commit is contained in:
@@ -769,7 +769,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
userIndicatorController: flowParameters.userIndicatorController,
|
||||
notificationSettings: userSession.clientProxy.notificationSettings,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appMediator: flowParameters.appMediator,
|
||||
appSettings: flowParameters.appSettings)
|
||||
let coordinator = RoomDetailsScreenCoordinator(parameters: params)
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
|
||||
@@ -239,6 +239,29 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
let reachabilityNotificationID = "io.element.elementx.reachability.notification"
|
||||
userSession.clientProxy.homeserverReachabilityPublisher.removeDuplicates()
|
||||
.combineLatest(flowParameters.appMediator.networkMonitor.reachabilityPublisher.removeDuplicates())
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] homeserverReachability, networkReachability in
|
||||
MXLog.info("Homeserver reachability: \(homeserverReachability)")
|
||||
|
||||
guard let self else { return }
|
||||
switch (homeserverReachability, networkReachability) {
|
||||
case (.reachable, _):
|
||||
flowParameters.userIndicatorController.retractIndicatorWithId(reachabilityNotificationID)
|
||||
case (.unreachable, .unreachable):
|
||||
flowParameters.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationID,
|
||||
title: L10n.commonOffline,
|
||||
persistent: true))
|
||||
case (.unreachable, .reachable):
|
||||
flowParameters.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationID,
|
||||
title: L10n.commonServerUnreachable,
|
||||
persistent: true))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
onboardingFlowCoordinator.actions
|
||||
.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
@@ -507,7 +530,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
private func presentSecureBackupLogoutConfirmationScreen() {
|
||||
let coordinator = SecureBackupLogoutConfirmationScreenCoordinator(parameters: .init(secureBackupController: userSession.clientProxy.secureBackupController,
|
||||
appMediator: flowParameters.appMediator))
|
||||
homeserverReachabilityPublisher: userSession.clientProxy.homeserverReachabilityPublisher))
|
||||
|
||||
coordinator.actions
|
||||
.sink { [weak self] action in
|
||||
|
||||
Reference in New Issue
Block a user