fix self-chat read state: mark own outgoing messages as read locally
iOS CI / Build and Test SwiftUI App (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build Unsigned iOS IPA (push) Canceled after 0s
Build Unsigned iOS and macOS Apps / Build macOS ZIP (push) Canceled after 0s

Self-chat returned early in sendDisplayedMarkerIfNeeded, so outgoing
messages never reached markRead and never showed the Read status.
This commit is contained in:
wt
2026-09-18 11:59:56 +07:00
parent 16c9fab509
commit 8a2af872d6
2 changed files with 20 additions and 2 deletions
+16 -2
View File
@@ -2534,11 +2534,25 @@ final class AppModel: ObservableObject {
/// Sends an XEP-0333 `<displayed/>` marker for the newest incoming 1:1
/// message once the chat is opened, so the peer's client can show it as
/// read. MUC rooms never get markers (XEP-0333); deduped per message so
/// repeated SwiftUI appearances do not resend.
/// repeated SwiftUI appearances do not resend. Self-chat has no peer, so
/// its own outgoing messages are promoted to `.read` locally instead of
/// sending a marker to our own bare JID.
private func sendDisplayedMarkerIfNeeded(for conversationID: String) {
guard let account else { return }
let normalized = conversationID.lowercased()
guard normalized != account.normalizedJID else { return }
if normalized == account.normalizedJID {
for index in messages.indices {
let message = messages[index]
guard message.conversationID == normalized,
message.direction == .outgoing,
message.delivery != .failed,
!message.isRetracted,
message.kind != .system
else { continue }
markRead(at: index, cameFromPeer: false)
}
return
}
guard let latest = messages
.filter({ $0.conversationID == normalized && $0.direction == .incoming })
.max(by: { $0.timestamp < $1.timestamp }),