mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 20:05:19 +00:00
Add comprehensive logging and force UI updates for delivery status
- Add logging to track what delivery status is shown in UI - Add logging when green/blue checkmarks appear - Force complete dictionary reassignment to trigger SwiftUI updates - Add diagnostics to understand why blue checkmarks aren't showing
This commit is contained in:
@@ -946,7 +946,14 @@ class ChatViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPrivateChatMessages(for peerID: String) -> [BitchatMessage] {
|
func getPrivateChatMessages(for peerID: String) -> [BitchatMessage] {
|
||||||
return privateChats[peerID] ?? []
|
let messages = privateChats[peerID] ?? []
|
||||||
|
if !messages.isEmpty {
|
||||||
|
print("[UI] Getting \(messages.count) messages for peer \(peerID)")
|
||||||
|
if let lastMessage = messages.last {
|
||||||
|
print("[UI] Last message status: \(lastMessage.deliveryStatus?.displayText ?? "none")")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return messages
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPeerIDForNickname(_ nickname: String) -> String? {
|
func getPeerIDForNickname(_ nickname: String) -> String? {
|
||||||
@@ -2135,21 +2142,24 @@ extension ChatViewModel: BitchatDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update in private chats
|
// Update in private chats
|
||||||
for (peerID, var chatMessages) in privateChats {
|
var updatedPrivateChats = privateChats
|
||||||
|
for (peerID, var chatMessages) in updatedPrivateChats {
|
||||||
if let index = chatMessages.firstIndex(where: { $0.id == messageID }) {
|
if let index = chatMessages.firstIndex(where: { $0.id == messageID }) {
|
||||||
var updatedMessage = chatMessages[index]
|
var updatedMessage = chatMessages[index]
|
||||||
updatedMessage.deliveryStatus = status
|
updatedMessage.deliveryStatus = status
|
||||||
chatMessages[index] = updatedMessage
|
chatMessages[index] = updatedMessage
|
||||||
privateChats[peerID] = chatMessages
|
updatedPrivateChats[peerID] = chatMessages
|
||||||
print("[Delivery] Updated message in private chat with \(peerID)")
|
print("[Delivery] Updated message in private chat with \(peerID)")
|
||||||
|
|
||||||
// Force UI update by triggering objectWillChange
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
|
||||||
self?.objectWillChange.send()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force complete reassignment to trigger SwiftUI update
|
||||||
|
DispatchQueue.main.async { [weak self] in
|
||||||
|
guard let self = self else { return }
|
||||||
|
self.privateChats = updatedPrivateChats
|
||||||
|
self.objectWillChange.send()
|
||||||
|
}
|
||||||
|
|
||||||
// Update in room messages
|
// Update in room messages
|
||||||
for (room, var roomMsgs) in roomMessages {
|
for (room, var roomMsgs) in roomMessages {
|
||||||
if let index = roomMsgs.firstIndex(where: { $0.id == messageID }) {
|
if let index = roomMsgs.firstIndex(where: { $0.id == messageID }) {
|
||||||
|
|||||||
@@ -494,6 +494,7 @@ struct ContentView: View {
|
|||||||
// Delivery status indicator for private messages
|
// Delivery status indicator for private messages
|
||||||
if message.isPrivate && message.sender == viewModel.nickname,
|
if message.isPrivate && message.sender == viewModel.nickname,
|
||||||
let status = message.deliveryStatus {
|
let status = message.deliveryStatus {
|
||||||
|
let _ = print("[UI] Message \(message.id) has status: \(status)")
|
||||||
DeliveryStatusView(status: status, colorScheme: colorScheme)
|
DeliveryStatusView(status: status, colorScheme: colorScheme)
|
||||||
.padding(.leading, 4)
|
.padding(.leading, 4)
|
||||||
.alignmentGuide(.firstTextBaseline) { _ in 12 }
|
.alignmentGuide(.firstTextBaseline) { _ in 12 }
|
||||||
@@ -1104,6 +1105,9 @@ struct DeliveryStatusView: View {
|
|||||||
}
|
}
|
||||||
.foregroundColor(textColor.opacity(0.8))
|
.foregroundColor(textColor.opacity(0.8))
|
||||||
.help("Delivered to \(nickname)")
|
.help("Delivered to \(nickname)")
|
||||||
|
.onAppear {
|
||||||
|
print("[UI] Showing GREEN checkmarks for delivered status to \(nickname)")
|
||||||
|
}
|
||||||
|
|
||||||
case .read(let nickname, _):
|
case .read(let nickname, _):
|
||||||
HStack(spacing: -2) {
|
HStack(spacing: -2) {
|
||||||
@@ -1114,6 +1118,9 @@ struct DeliveryStatusView: View {
|
|||||||
}
|
}
|
||||||
.foregroundColor(Color.blue)
|
.foregroundColor(Color.blue)
|
||||||
.help("Read by \(nickname)")
|
.help("Read by \(nickname)")
|
||||||
|
.onAppear {
|
||||||
|
print("[UI] Showing BLUE checkmarks for read status by \(nickname)")
|
||||||
|
}
|
||||||
|
|
||||||
case .failed(let reason):
|
case .failed(let reason):
|
||||||
Image(systemName: "exclamationmark.triangle")
|
Image(systemName: "exclamationmark.triangle")
|
||||||
|
|||||||
Reference in New Issue
Block a user