mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 23:45:18 +00:00
Fix read receipts and improve UI
- Changed back to bold blue double checkmarks for read status - Send read receipts for both 'sent' and 'delivered' status messages - Added onChange handler to send read receipts whenever switching to a private chat - Made markPrivateMessagesAsRead public so it can be called from views - This ensures read receipts are sent when opening a chat from notifications or any other way
This commit is contained in:
@@ -895,7 +895,7 @@ class ChatViewModel: ObservableObject {
|
||||
selectedPrivateChatPeer = nil
|
||||
}
|
||||
|
||||
private func markPrivateMessagesAsRead(from peerID: String) {
|
||||
func markPrivateMessagesAsRead(from peerID: String) {
|
||||
guard let messages = privateChats[peerID] else {
|
||||
print("[Delivery] No messages found for peer \(peerID)")
|
||||
return
|
||||
@@ -912,8 +912,8 @@ class ChatViewModel: ObservableObject {
|
||||
if message.senderPeerID == peerID {
|
||||
if let status = message.deliveryStatus {
|
||||
switch status {
|
||||
case .delivered:
|
||||
// Create and send read receipt
|
||||
case .sent, .delivered:
|
||||
// Create and send read receipt for sent or delivered messages
|
||||
// Use the senderPeerID from the message to ensure it goes to the right peer
|
||||
if let messageSenderID = message.senderPeerID {
|
||||
let receipt = ReadReceipt(
|
||||
|
||||
@@ -528,6 +528,12 @@ 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,10 +1117,12 @@ struct DeliveryStatusView: View {
|
||||
|
||||
case .read(let nickname, _):
|
||||
HStack(spacing: -2) {
|
||||
Image(systemName: "checkmark.circle.fill")
|
||||
.font(.system(size: 12, weight: .bold))
|
||||
.foregroundColor(Color(red: 0.0, green: 0.478, blue: 1.0)) // Bright blue
|
||||
Image(systemName: "checkmark")
|
||||
.font(.system(size: 10, weight: .bold))
|
||||
Image(systemName: "checkmark")
|
||||
.font(.system(size: 10, weight: .bold))
|
||||
}
|
||||
.foregroundColor(Color(red: 0.0, green: 0.478, blue: 1.0)) // Bright blue
|
||||
.help("Read by \(nickname)")
|
||||
.onAppear {
|
||||
print("[UI] Showing BLUE checkmarks for read status by \(nickname)")
|
||||
|
||||
Reference in New Issue
Block a user