mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 03:45:21 +00:00
Fix store-and-forward duplicate message delivery and timestamp ordering
- Add tracking to prevent sending cached messages multiple times to the same peer - Only cache messages for offline favorites, not online ones - Sort messages by timestamp when adding to ensure proper chronological order - Clean up tracking sets when peers disconnect to allow re-sending on reconnect - Cache our own messages when sending to offline favorites - Update favorite online notification text to "wanna get in there?"
This commit is contained in:
@@ -492,6 +492,8 @@ extension ChatViewModel: BitchatDelegate {
|
||||
privateChats[peerID] = []
|
||||
}
|
||||
privateChats[peerID]?.append(message)
|
||||
// Sort messages by timestamp to ensure proper ordering
|
||||
privateChats[peerID]?.sort { $0.timestamp < $1.timestamp }
|
||||
|
||||
// Trigger UI update for private chats
|
||||
objectWillChange.send()
|
||||
@@ -510,6 +512,8 @@ extension ChatViewModel: BitchatDelegate {
|
||||
} else {
|
||||
// Regular public message
|
||||
messages.append(message)
|
||||
// Sort messages by timestamp to ensure proper ordering
|
||||
messages.sort { $0.timestamp < $1.timestamp }
|
||||
}
|
||||
|
||||
// Check if we're mentioned
|
||||
|
||||
Reference in New Issue
Block a user