mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Debounce message sending queue re-enabling requests
This commit is contained in:
committed by
Stefan Ceriu
parent
6c1647b851
commit
660b8243bc
@@ -121,6 +121,8 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
verificationStateSubject.asCurrentValuePublisher()
|
verificationStateSubject.asCurrentValuePublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let sendingQueueStatusSubject = CurrentValueSubject<Bool, Never>(false)
|
||||||
|
|
||||||
init(client: ClientProtocol,
|
init(client: ClientProtocol,
|
||||||
appSettings: AppSettings,
|
appSettings: AppSettings,
|
||||||
networkMonitor: NetworkMonitorProtocol) async {
|
networkMonitor: NetworkMonitorProtocol) async {
|
||||||
@@ -166,15 +168,23 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
})
|
})
|
||||||
|
|
||||||
sendingQueueListenerTaskHandle = client.subscribeToSendingQueueStatus(listener: SendingQueueStatusListenerProxy { [weak self] enabled in
|
sendingQueueListenerTaskHandle = client.subscribeToSendingQueueStatus(listener: SendingQueueStatusListenerProxy { [weak self] enabled in
|
||||||
|
self?.sendingQueueStatusSubject.send(enabled)
|
||||||
|
})
|
||||||
|
|
||||||
|
sendingQueueStatusSubject
|
||||||
|
.removeDuplicates()
|
||||||
|
.debounce(for: 0.25, scheduler: DispatchQueue.main)
|
||||||
|
.sink { [weak self] enabled in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
MXLog.error("Sending queue status changed to enabled: \(enabled)")
|
MXLog.info("Sending queue status changed to enabled: \(enabled)")
|
||||||
|
|
||||||
if enabled == false,
|
if enabled == false,
|
||||||
networkMonitor.reachabilityPublisher.value == .reachable {
|
networkMonitor.reachabilityPublisher.value == .reachable {
|
||||||
setSendingQueueEnabled(true)
|
setSendingQueueEnabled(true)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateVerificationState(_ verificationState: VerificationState) {
|
private func updateVerificationState(_ verificationState: VerificationState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user