Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Upcoming

### 🔄 Changed
### 🐞 Fixed
- Fix reading messages from muted users [#1063](https://github.com/GetStream/stream-chat-swiftui/pull/1063)

# [4.94.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.94.0)
_December 02, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,11 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
}

private func sendReadEventIfNeeded(for message: ChatMessage) {
guard let channel, channel.unreadCount.messages > 0 else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since unread count did not change when a muted user sent a message then we never called mark read

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have the same issue on UIKit? I think I introduced this logic recently in UIKit as well 🤔

guard let channel, let currentUserId = chatClient.currentUserId else { return }
if currentUserMarkedMessageUnread {
return
}
if currentUserMarkedMessageUnread {
if let read = channel.read(for: currentUserId), read.lastReadAt > message.createdAt {
return
}
throttler.execute { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,36 @@ class ChatChannelViewModel_Tests: StreamChatTestCase {
XCTAssertEqual(1, channelController.markReadCallCount)
}

func test_chatChannelVM_sendReadEventIfNeeded_whenChannelHasNoUnreadMessages() {
func test_chatChannelVM_sendReadEventIfNeeded_whenChannelHasNoReads_thenMarkReadIsCalled() {
// Given
let message = ChatMessage.mock()
let channelController = makeChannelController(messages: [message])
channelController.channel_mock = .mock(cid: .unique, unreadCount: ChannelUnreadCount(messages: 0, mentions: 0))
channelController.channel_mock = .mockDMChannel(reads: [])
channelController.hasLoadedAllNextMessages_mock = true
let viewModel = ChatChannelViewModel(channelController: channelController)
viewModel.currentUserMarkedMessageUnread = false
viewModel.throttler = Throttler_Mock(interval: 0)

// When
viewModel.handleMessageAppear(index: 0, scrollDirection: .down)

// Then
XCTAssertEqual(1, channelController.markReadCallCount)
}

func test_chatChannelVM_sendReadEventIfNeeded_whenChannelReadHasMoreRecentTimestamp_thenMarkReadIsNotCalled() {
// Given
let message = ChatMessage.mock()
let channelController = makeChannelController(messages: [message])
channelController.channel_mock = .mockDMChannel(
reads: [.mock(
lastReadAt: .distantFuture,
lastReadMessageId: .unique,
unreadMessagesCount: 0,
user: .mock(id: chatClient.currentUserId ?? "")
)]
)
channelController.hasLoadedAllNextMessages_mock = true
let viewModel = ChatChannelViewModel(channelController: channelController)
viewModel.currentUserMarkedMessageUnread = false
viewModel.throttler = Throttler_Mock(interval: 0)
Expand Down
Loading