From f90f0776364860499a0d627e124f012e51478d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jc=20Mi=C3=B1arro?= Date: Thu, 4 Apr 2024 09:56:43 +0200 Subject: [PATCH] Not increase unread counter when an shadowed message arrives --- .../chat/android/client/extensions/internal/Channel.kt | 3 ++- .../state/plugin/logic/channel/internal/ChannelStateLogic.kt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Channel.kt b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Channel.kt index a7eaffe7d01..60f6c6e2173 100644 --- a/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Channel.kt +++ b/stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Channel.kt @@ -69,7 +69,8 @@ public fun Channel.updateLastMessage( unreadMessages = read.let { val hasNewUnreadMessage = receivedEventDate.after(it.lastReceivedEventDate) && newMessages.size > messages.size && - newMessages.last().id == message.id + newMessages.last().id == message.id && + !message.shadowed if (hasNewUnreadMessage) it.unreadMessages.inc() else it.unreadMessages }, ) diff --git a/stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogic.kt b/stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogic.kt index 85b944003c1..85e4cc7f328 100644 --- a/stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogic.kt +++ b/stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/channel/internal/ChannelStateLogic.kt @@ -660,6 +660,7 @@ internal class ChannelStateLogic( message.user.id == clientState.user.value?.id || message.parentId?.takeUnless { message.showInChannel } != null } + ?.takeUnless { message.shadowed } ?.let { updateRead( it.copy(