mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-09-19 04:59:59 +00:00
sendCachedMessages is latched per peer by cachedMessagesSentToPeer, and nothing ever removed a peer from that set. So a peer received whatever was held for it on its first connection of the session, and every later reconnection was refused at the top of the function. Mail queued while it was away sat in the cache until it aged out. The latch means "this peer has been handed everything we hold". Caching new mail for that peer is exactly the event that stops being true, so release it there. A reconnect with nothing new still sends nothing, which is what the latch is for. Also stops the periodic cleanup wiping both tracking sets outright. Emptying them bounded memory by forgetting: deliveredMessages is what keeps an already-delivered message from being queued again, and the peer latch is what keeps a batch from being sent twice. Both are now insertion-ordered and trimmed to their cap oldest-first.