feat(chat): stabilize multi-image attachment picker (#986)

This commit is contained in:
AlexDev_
2026-08-27 10:50:55 +03:00
committed by GitHub
parent c7d7abf4a1
commit 0ae5ed4db2
11 changed files with 432 additions and 55 deletions
@@ -97,6 +97,7 @@ object HermesWsClient {
private val intentionalClose = AtomicBoolean(false)
private val acceptQueuedMessages = AtomicBoolean(true)
private val appInForeground = AtomicBoolean(true)
private val externalActivityConnectionLease = AtomicBoolean(false)
private val messageQueue = ConcurrentLinkedQueue<String>()
private val queuedMessagesById = ConcurrentHashMap<String, String>()
private val outboundLock = Any()
@@ -285,9 +286,19 @@ object HermesWsClient {
if (!foreground) disconnectIfIdleInBackground()
}
fun acquireExternalActivityConnectionLease() {
externalActivityConnectionLease.set(true)
}
fun releaseExternalActivityConnectionLease() {
externalActivityConnectionLease.set(false)
disconnectIfIdleInBackground()
}
private fun disconnectIfIdleInBackground() {
synchronized(outboundLock) {
if (!appInForeground.get() &&
!externalActivityConnectionLease.get() &&
!pendingReply &&
pendingCalls.isEmpty() &&
messageQueue.isEmpty()