Skip to content

Fix mark unread action not removed when read events are disabled #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add extra data to user display info [#819](https://github.com/GetStream/stream-chat-swiftui/pull/819)
### 🐞 Fixed
- Fix swipe to reply enabled when quoting a message is disabled [#824](https://github.com/GetStream/stream-chat-swiftui/pull/824)
- Fix mark unread action not removed when read events are disabled [#823](https://github.com/GetStream/stream-chat-swiftui/pull/823)

# [4.78.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.78.0)
_April 24, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public extension MessageAction {
)
messageActions.append(markThreadUnreadAction)
}
} else if !message.isSentByCurrentUser {
} else if !message.isSentByCurrentUser && channel.canReceiveReadEvents {
if !message.isPartOfThread || message.showReplyInChannel {
let markUnreadAction = markAsUnreadAction(
for: message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MessageActionsViewModel_Tests: StreamChatTestCase {
text: "test",
author: .mock(id: .unique)
),
channel: .mockDMChannel(ownCapabilities: [.sendMessage, .uploadFile, .pinMessage]),
channel: .mockDMChannel(ownCapabilities: [.sendMessage, .uploadFile, .pinMessage, .readEvents]),
chatClient: chatClient,
onFinish: { _ in },
onError: { _ in }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,38 @@ class MessageActions_Tests: StreamChatTestCase {
XCTAssert(messageActions[4].title == "Mark Unread")
XCTAssert(messageActions[5].title == "Mute User")
}


func test_messageActions_otherUserDefaultReadEventsDisabled() {
// Given
let channel = ChatChannel.mockDMChannel(ownCapabilities: [.sendMessage, .uploadFile, .pinMessage])
let message = ChatMessage.mock(
id: .unique,
cid: channel.cid,
text: "Test",
author: .mock(id: .unique),
isSentByCurrentUser: false
)
let factory = DefaultViewFactory.shared

// When
let messageActions = MessageAction.defaultActions(
factory: factory,
for: message,
channel: channel,
chatClient: chatClient,
onFinish: { _ in },
onError: { _ in }
)

// Then
XCTAssert(messageActions.count == 5)
XCTAssert(messageActions[0].title == "Reply")
XCTAssert(messageActions[1].title == "Thread Reply")
XCTAssert(messageActions[2].title == "Pin to conversation")
XCTAssert(messageActions[3].title == "Copy Message")
XCTAssert(messageActions[4].title == "Mute User")
}

func test_messageActions_otherUserDefaultBlockingEnabled() {
// Given
streamChat = StreamChat(
Expand Down Expand Up @@ -297,7 +328,7 @@ class MessageActions_Tests: StreamChatTestCase {

private var mockDMChannel: ChatChannel {
ChatChannel.mockDMChannel(
ownCapabilities: [.sendMessage, .uploadFile, .pinMessage]
ownCapabilities: [.sendMessage, .uploadFile, .pinMessage, .readEvents]
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class ReactionsOverlayView_Tests: StreamChatTestCase {
let view = VerticallyCenteredView {
ReactionsOverlayView(
factory: DefaultViewFactory.shared,
channel: .mockDMChannel(ownCapabilities: [.sendMessage, .uploadFile, .pinMessage]),
channel: .mockDMChannel(ownCapabilities: [.sendMessage, .uploadFile, .pinMessage, .readEvents]),
currentSnapshot: self.overlayImage,
messageDisplayInfo: messageDisplayInfo,
onBackgroundTap: {},
Expand Down
Loading