channel.getUnreadItemCount - groupChannelUnreadMentionCount does not get updated

[Problem/Question]
Hello, I have some issues with the groupChannelUnreadMentionCount value, returned from channel.getUnreadItemCount() not being updated. Usage attached below.

When I receive a new mention, the groupChannelUnreadMentionCount is increased.

If I go to the channel, with that mention, and call channel.getUnreadItemCount() again, the groupChannelUnreadMentionCount stays the same ( does not get reduced to 0).

  • in this scenario, the groupChannelUnreadMessageCount is updated correctly, only the groupChannelUnreadMentionCount is not.

The only way to get groupChannelUnreadMentionCount to go down is to :

  1. Go to the channel with the mention
  2. Receive another mention

The expected behaviour would be for groupChannelUnreadMentionCount to work like groupChannelUnreadMessageCount. ( No need to receive another message or mention, for the value to update, while using the channel.getUnreadItemCount() method ).


[SDK Version]
4.8.1

[Reproduction Steps]

Usage:
const params: UnreadItemCountParams = {
keys: [
UnreadItemKey.SUPER_UNREAD_MENTION_COUNT,
UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT,
UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT,
],
};

const unreadMentionsCount: UnreadItemCount | undefined =
await sb?.groupChannel.getUnreadItemCount(params);

Steps:

  1. receive a mention for you user in any channel;
  2. call sb?.groupChannel.getUnreadItemCount(params) with the UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT param;
  3. open the channel;
  4. repeat step 2;

[Frequency]
Every time.

[Current impact]
I cannot display the unreadMentionsCount in the UI.

Hello @temp-acc

Welcome to the Sendbird community!

Based on the provided information, it seems that the issue you are facing is related to the behavior of the groupChannelUnreadMentionCount value returned from the channel.getUnreadItemCount() method.

According to the documentation, the groupChannelUnreadMentionCount represents the number of messages in group channels and Supergroup channels where the user was mentioned but hasn’t read. However, you mentioned that when you go to the channel with the mention and call channel.getUnreadItemCount() again, the groupChannelUnreadMentionCount value does not get reduced to 0.

In this case, it’s important to note that the groupChannelUnreadMentionCount value is not automatically updated when you view the channel with the mention. It only gets updated when you receive another mention. This behavior is different from the groupChannelUnreadMessageCount, which is updated correctly.

To achieve the expected behavior, where the groupChannelUnreadMentionCount value updates without the need to receive another mention, you may need to implement a custom logic. One possible approach is to manually update the groupChannelUnreadMentionCount value when the user views the channel with the mention. You can do this by listening to the onUnreadMemberStatusUpdated event and checking if the user has read the mention message. If the user has read the mention message, you can update the groupChannelUnreadMentionCount value accordingly.

By implementing this custom logic, you can ensure that the groupChannelUnreadMentionCount value is updated when the user views the channel with the mention, without the need to receive another mention.

Hi, @Chinmaya_Gupta,

Thank you for the welcome.

I think the solution you provided does not work, because that event fires on all of the other devices, except the current user, who opened the channel with the mention (pic. related)

Furthermore, even if it worked, then either after a page refresh, or after another mention was received, the unreadMentionsCount would get out of sync again. I truly think this is a bug on the sendbird part, because the name of the method ( channel.getUnreadItemCount() ) implies, that I will get the unreadItemCount at the time of calling the function, which is not the case for mentions, but is the case for messages somehow. (why the discrepancy ?)

Best regards, Ignas