mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
#1257 - Prevent the syncing indicator from showing over the offline one
This commit is contained in:
committed by
Stefan Ceriu
parent
59865a4b16
commit
56544d6604
@@ -475,10 +475,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
networkMonitorObserver = ServiceLocator.shared.networkMonitor
|
||||
.reachabilityPublisher
|
||||
.removeDuplicates()
|
||||
.sink { reachable in
|
||||
MXLog.info("Reachability changed to \(reachable)")
|
||||
.sink { reachability in
|
||||
MXLog.info("Reachability changed to \(reachability)")
|
||||
|
||||
if reachable {
|
||||
if reachability == .reachable {
|
||||
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(reachabilityNotificationIdentifier)
|
||||
} else {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: reachabilityNotificationIdentifier,
|
||||
@@ -566,7 +566,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: identifier, type: .toast(progress: .indeterminate), title: L10n.commonSyncing, persistent: true))
|
||||
}
|
||||
|
||||
showLoadingIndicator()
|
||||
// Prevent the syncing indicator from showing over the offline one
|
||||
if ServiceLocator.shared.networkMonitor.reachabilityPublisher.value == .reachable {
|
||||
showLoadingIndicator()
|
||||
}
|
||||
|
||||
clientProxyObserver = userSession.clientProxy
|
||||
.callbacks
|
||||
|
||||
@@ -18,10 +18,19 @@ import Combine
|
||||
import Foundation
|
||||
import Network
|
||||
|
||||
enum NetworkMonitorReachability {
|
||||
case reachable
|
||||
case unreachable
|
||||
}
|
||||
|
||||
class NetworkMonitor {
|
||||
private let pathMonitor: NWPathMonitor
|
||||
private let queue: DispatchQueue
|
||||
let reachabilityPublisher: CurrentValueSubject<Bool, Never>
|
||||
|
||||
private let reachabilitySubject: CurrentValueSubject<NetworkMonitorReachability, Never>
|
||||
var reachabilityPublisher: CurrentValuePublisher<NetworkMonitorReachability, Never> {
|
||||
reachabilitySubject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
var isCurrentConnectionExpensive: Bool {
|
||||
pathMonitor.currentPath.isExpensive
|
||||
@@ -34,14 +43,14 @@ class NetworkMonitor {
|
||||
init() {
|
||||
queue = DispatchQueue(label: "io.element.elementx.networkmonitor", qos: .background)
|
||||
pathMonitor = NWPathMonitor()
|
||||
reachabilityPublisher = CurrentValueSubject<Bool, Never>(true)
|
||||
reachabilitySubject = CurrentValueSubject<NetworkMonitorReachability, Never>(.reachable)
|
||||
|
||||
pathMonitor.pathUpdateHandler = { [weak self] path in
|
||||
DispatchQueue.main.async {
|
||||
if path.status == .satisfied {
|
||||
self?.reachabilityPublisher.send(true)
|
||||
self?.reachabilitySubject.send(.reachable)
|
||||
} else {
|
||||
self?.reachabilityPublisher.send(false)
|
||||
self?.reachabilitySubject.send(.unreachable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user