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 committed 2026-09-18 11:59:56 +07:00
1 parent 16c9fab509
commit 8a2af872d6
2 files changed
+20 -2

No files matched your search

+4
View File
@@ -425,6 +425,10 @@ grep -q 'markersPublisher' Sources/Shared/XMPP/XMPPService.swift || {
echo "XEP-0333 displayed markers must mark messages as read"
exit 1
}
grep -q 'markRead(at: index, cameFromPeer: false)' Sources/Shared/Models/AppModel.swift || {
echo "Self-chat must mark its own outgoing messages as read locally"
exit 1
}
grep -q 'case read(conversationJID' Sources/Shared/XMPP/XMPPService.swift || {
echo "Read receipts must reference the conversation"
exit 1
+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 }),