diff --git a/bitchat/ViewModels/ChatTransportEventCoordinator.swift b/bitchat/ViewModels/ChatTransportEventCoordinator.swift index 7fcac671..84c6a288 100644 --- a/bitchat/ViewModels/ChatTransportEventCoordinator.swift +++ b/bitchat/ViewModels/ChatTransportEventCoordinator.swift @@ -98,8 +98,7 @@ extension ChatViewModel: ChatTransportEventContext { // `unreadPrivateMessages`, `selectedPrivateChatPeer`, `notifyUIChanged()`, // the inbound message handlers, `isPeerBlocked(_:)`, // `parseMentions(from:)`, `resolveNickname(for:)`, - // `cacheStablePeerID(_:for:)`, `cachedStablePeerID(for:)`, and - // `retryPendingReadReceiptsIfViewing(peerIDAliases:)` are shared + // `cacheStablePeerID(_:for:)`, and `cachedStablePeerID(for:)` are shared // requirements with the other contexts or satisfied by existing // `ChatViewModel` members. The single-writer intent op // `unmarkReadReceiptsSent(_:)` lives next to its backing state in @@ -122,6 +121,15 @@ extension ChatViewModel: ChatTransportEventContext { messageRouter.failOverOutbox(for: peerIDAliases, excluding: meshService) } + func retryPendingReadReceiptsIfViewing(peerIDAliases: [PeerID]) { + guard isAppActive, let selected = selectedPrivateChatPeer else { return } + let aliasSet = Set(peerIDAliases) + let shortAliases = Set(peerIDAliases.map { $0.toShort() }) + if aliasSet.contains(selected) || shortAliases.contains(selected.toShort()) { + markPrivateMessagesAsRead(from: selected) + } + } + func retryCourierDeposits(via peerID: PeerID) { messageRouter.courierBecameAvailable(peerID) }