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