Skip to content

Commit 8823901

Browse files
committed
Fix double mark unread action
1 parent 37ad5c0 commit 8823901

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Reactions/MessageActions/DefaultMessageActions.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ extension MessageAction {
116116
.makeMessageController(for: message.id, channelId: channel.cid)
117117
// At the moment, this is the only way to know if we are inside a thread.
118118
// This should be optimised in the future and provide the view context.
119-
if messageController.replies.count > 0 {
119+
let isInsideThreadView = messageController.replies.count > 0
120+
if isInsideThreadView {
120121
let markThreadUnreadAction = markThreadAsUnreadAction(
121122
messageController: messageController,
122123
message: message,
@@ -125,6 +126,18 @@ extension MessageAction {
125126
)
126127
messageActions.append(markThreadUnreadAction)
127128
}
129+
} else if !message.isSentByCurrentUser {
130+
if !message.isPartOfThread || message.showReplyInChannel {
131+
let markUnreadAction = markAsUnreadAction(
132+
for: message,
133+
channel: channel,
134+
chatClient: chatClient,
135+
onFinish: onFinish,
136+
onError: onError
137+
)
138+
139+
messageActions.append(markUnreadAction)
140+
}
128141
}
129142

130143
if message.isSentByCurrentUser {
@@ -147,18 +160,6 @@ extension MessageAction {
147160

148161
messageActions.append(deleteAction)
149162
} else {
150-
if !message.isPartOfThread || message.showReplyInChannel {
151-
let markUnreadAction = markAsUnreadAction(
152-
for: message,
153-
channel: channel,
154-
chatClient: chatClient,
155-
onFinish: onFinish,
156-
onError: onError
157-
)
158-
159-
messageActions.append(markUnreadAction)
160-
}
161-
162163
if channel.canFlagMessage {
163164
let flagAction = flagMessageAction(
164165
for: message,

0 commit comments

Comments
 (0)