mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +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:
@@ -150,7 +150,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
setupStateMachine()
|
||||
|
||||
observeApplicationState()
|
||||
observeNetworkState()
|
||||
observeAppLockChanges()
|
||||
|
||||
registerBackgroundAppRefresh()
|
||||
@@ -826,24 +825,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
}
|
||||
|
||||
private func observeNetworkState() {
|
||||
let reachabilityNotificationIdentifier = "io.element.elementx.reachability.notification"
|
||||
appMediator.networkMonitor
|
||||
.reachabilityPublisher
|
||||
.sink { reachability in
|
||||
MXLog.info("Reachability changed to \(reachability)")
|
||||
|
||||
if reachability == .reachable {
|
||||
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(reachabilityNotificationIdentifier)
|
||||
} else {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationIdentifier,
|
||||
title: L10n.commonOffline,
|
||||
persistent: true))
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func observeAppLockChanges() {
|
||||
appLockFlowCoordinator.actions.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
@@ -1046,7 +1027,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
switch state {
|
||||
case .loading:
|
||||
if self?.appMediator.networkMonitor.reachabilityPublisher.value == .reachable {
|
||||
if self?.userSession?.clientProxy.homeserverReachabilityPublisher.value == .reachable {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: toastIdentifier, type: .toast(progress: .indeterminate), title: L10n.commonSyncing, persistent: true))
|
||||
}
|
||||
case .notLoading:
|
||||
|
||||
Reference in New Issue
Block a user