# Incorrect unread message count

**URL:** <https://forum.social.plus/t/incorrect-unread-message-count/1736>\
**Category:** TS SDK\
**Created:** [May 29, 2025, 4:11am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736 "2025-05-29T04:11:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [May 29, 2025, 4:11am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/1 "2025-05-29T04:11:26Z")

</div>

Despite calling the markAsRead method on all chats (I have two), Client.getUserUnread returns an incorrect value of 1. I wanted to be extra sure, that I’m not missing anything so I also did the same for evety single message in the chat.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [May 29, 2025, 5:37am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/2 "2025-05-29T05:37:38Z")

</div>

Hello @jfiejka ,  
Thanks for the details! Could you also share:

- The platform and SDK version you’re using
- Code snippets where you’re calling `markAsRead()` and `Client.getUserUnread()`

This will help us reproduce and check on our side.

---

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [May 29, 2025, 8:02am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/3 "2025-05-29T08:02:45Z")

</div>

I’m using ts-sdk 7.2.0 and this is how my code looks like

```auto
const unreadCount = ref(0);
const channels = ref([]);

const unsubscribeUnreadCount = Client.getUserUnread(({ data }) => {
  if (data) {
    unreadCount.value = data.unreadCount;
  }
});

const unsubscribeChannels = ChannelRepository.getChannels({
  membership: "member",
  limit: 30,
  isDeleted: false
}, ({ data }) => {

  if (data) {
    channels.value = data;
  }
});

```

In another place when I display a single chat:

```auto
const { id } = defineProps<{ id: string }>();

const chat = ref();

const unsubscribeChannel = ChannelRepository.getChannel(id, ({ error, data, loading }) => {
  if (error) console.error(error);
  if (data && !loading) {
    chat.value = data;

    if (data.subChannelsUnreadCount) {
      data.markAsRead();
    }
  }
});

```

The user for whom this error occurs has two chats and for both subChannelsUnreadCount and unreadCount is equal to 0 but getUserUnread somehow returns 1.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [May 30, 2025, 6:32am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/4 "2025-05-30T06:32:18Z")

</div>

Hello @jfiejka , Please make sure to call the unread sync function **before** retrieving unread counts.  
Refer to this section in our docs for details:

> **[Backup | Social+ Docs](https://docs.social.plus/social-plus-sdk/chat/channels/unread-count/backup#start-unread-count-syncing)**

Specifically, you should call the sync function first **before** using `getChannels` or `getUserUnread`, to ensure the count is accurate.

Let us know if the issue persists after that!

---

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [May 30, 2025, 9:02am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/5 "2025-05-30T09:02:23Z")

</div>

Unfortunately it didn’t help. It still returns incorrect value. Do you have any other suggestions?

Maybe there’s a way to check what message is unread?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [June 2, 2025, 11:07am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/6 "2025-06-02T11:07:01Z")

</div>

Hello @jfiejka, Thank you for the update. If possible, could you please share your updated code as well? We’ll pass it to our team for further review.

---

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [June 3, 2025, 9:11am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/7 "2025-06-03T09:11:34Z")

</div>

```
const unreadCount = ref(0);
const channels = ref([]);

const subscribeUnreadCount = () =>
    Client.getUserUnread(({ data }) => {
        if (data) {
            unreadCount.value = data.unreadCount;
        }
    });

const subscribeChannels = () =>
    ChannelRepository.getChannels(
        {
            membership: 'member',
            limit: 30,
            isDeleted: false,
        },
        ({ data }) => {
            if (data) {
                channels.value = data;
            }
        }
    );

const init = async () => {
    await Client.startUnreadSync();
    unsubscribeChannels = subscribeChannels();
    unsubscribeUnreadCount = subscribeUnreadCount();
};

```

Here you go. But you didn’t answer my question, is there a way to get unread messages?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [June 3, 2025, 10:25am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/8 "2025-06-03T10:25:16Z")

</div>

Thank you for sharing the code. Once our team has reviewed it, we’ll get back to you to confirm whether there are any alternative solutions. We appreciate your patience.

---

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [June 10, 2025, 7:28am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/9 "2025-06-10T07:28:01Z")

</div>

Hey, do you have any updates?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [June 11, 2025, 6:29am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/10 "2025-06-11T06:29:19Z")

</div>

Hello @jfiejka , Our team was unable to reproduce the issue on our side. However, we recommend using **mark message as read** instead of **mark channel as read** to ensure accurate unread counts.

Please refer to our documentation for more details:

> **[Mark Message as Read | Social+ Docs](https://docs.social.plus/social-plus-sdk/chat/channels/unread-count/mark-message-as-read)**

Let us know if you need further assistance or have any additional questions.

---

<div class="post-metadata">

**Author:** ![jfiejka](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@jfiejka](https://forum.social.plus/u/jfiejka)\
**Post date:** [June 11, 2025, 7:36am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/11 "2025-06-11T07:36:48Z")

</div>

I did both, marked channel as read and every message as read, I mentioned it in the first message. Didn’t help.

Also you still didn’t answer my question, how do I check what messages are unread?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [June 12, 2025, 9:24am UTC](https://forum.social.plus/t/incorrect-unread-message-count/1736/12 "2025-06-12T09:24:15Z")

</div>

Hello @jfiejka, our team is currently investigating and coordinating with your team via email. We’ll keep you updated there.
