mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:25:20 +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
|
selectedPrivateChatPeer = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
private func markPrivateMessagesAsRead(from peerID: String) {
|
func markPrivateMessagesAsRead(from peerID: String) {
|
||||||
guard let messages = privateChats[peerID] else {
|
guard let messages = privateChats[peerID] else {
|
||||||
print("[Delivery] No messages found for peer \(peerID)")
|
print("[Delivery] No messages found for peer \(peerID)")
|
||||||
return
|
return
|
||||||
@@ -912,8 +912,8 @@ class ChatViewModel: ObservableObject {
|
|||||||
if message.senderPeerID == peerID {
|
if message.senderPeerID == peerID {
|
||||||
if let status = message.deliveryStatus {
|
if let status = message.deliveryStatus {
|
||||||
switch status {
|
switch status {
|
||||||
case .delivered:
|
case .sent, .delivered:
|
||||||
// Create and send read receipt
|
// Create and send read receipt for sent or delivered messages
|
||||||
// Use the senderPeerID from the message to ensure it goes to the right peer
|
// Use the senderPeerID from the message to ensure it goes to the right peer
|
||||||
if let messageSenderID = message.senderPeerID {
|
if let messageSenderID = message.senderPeerID {
|
||||||
let receipt = ReadReceipt(
|
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, _):
|
case .read(let nickname, _):
|
||||||
HStack(spacing: -2) {
|
HStack(spacing: -2) {
|
||||||
Image(systemName: "checkmark.circle.fill")
|
Image(systemName: "checkmark")
|
||||||
.font(.system(size: 12, weight: .bold))
|
.font(.system(size: 10, weight: .bold))
|
||||||
.foregroundColor(Color(red: 0.0, green: 0.478, blue: 1.0)) // Bright blue
|
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)")
|
.help("Read by \(nickname)")
|
||||||
.onAppear {
|
.onAppear {
|
||||||
print("[UI] Showing BLUE checkmarks for read status by \(nickname)")
|
print("[UI] Showing BLUE checkmarks for read status by \(nickname)")
|
||||||
|
|||||||
Reference in New Issue
Block a user