mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:45:19 +00:00
Fix read receipts for existing messages when opening chat
- Added delay to ensure messages are loaded before checking - Fixed logic to check if message is FROM the other person (not TO them) - Added onAppear handler to send read receipts when view loads - Added detailed logging to debug the flow - Now correctly identifies received messages that need read receipts
This commit is contained in:
@@ -531,7 +531,18 @@ struct ContentView: View {
|
||||
.onChange(of: viewModel.selectedPrivateChatPeer) { newPeerID in
|
||||
// When switching to a private chat, send read receipts
|
||||
if let peerID = newPeerID {
|
||||
viewModel.markPrivateMessagesAsRead(from: peerID)
|
||||
// Small delay to ensure messages are loaded
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
viewModel.markPrivateMessagesAsRead(from: peerID)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
// Also check when view appears
|
||||
if let peerID = viewModel.selectedPrivateChatPeer {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
viewModel.markPrivateMessagesAsRead(from: peerID)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user