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:
jack
2025-07-04 15:02:49 +02:00
parent 3c894bcb2f
commit a569b87a18
3 changed files with 61 additions and 13 deletions
+4
View File
@@ -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