# getUserUnread()

**URL:** <https://forum.social.plus/t/getuserunread/1266>\
**Category:** TS SDK\
**Created:** [April 17, 2024, 12:07pm UTC](https://forum.social.plus/t/getuserunread/1266 "2024-04-17T12:07:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 17, 2024, 12:07pm UTC](https://forum.social.plus/t/getuserunread/1266/1 "2024-04-17T12:07:39Z")

</div>

Hi there,

I’m using the below effect to monitor unread for my logged in user.

I’ve created the below two functions to handle marking all messages unread upon opening up a specific page.

This works to the extent that it clears down the unread messages for the channel I am looking at.

The problem is, when the logged in user sends a message to that channel, I receive an Unread count of 1 (the message I have just sent).

I assumed that the unread count would not include this as it was generated by the logged in user?

Is this correct behaviour? If so what is the recommended way of handling?

Thanks.

```auto
  const handleMarkChannelAsRead = (subChannelId: string) => {
    //Async?
    const messagesByChannel = messages.filter(
      (msg) => msg.subChannelId === subChannelId
    )

    messagesByChannel.map((msg) => msg.markRead())
  }

```

```auto
  useEffect(() => {
    if (isConnected) {
      const handleLiveObject = (
        liveObject: Amity.LiveObject<Amity.UserUnread | undefined>
      ) => {
        if (liveObject.data) {
          const { unreadCount } = liveObject.data

          setUserUnreadCount(unreadCount)
        }
      }

      AmityClient.getUserUnread(handleLiveObject)
    }
  }, [isConnected])

```

---

<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:** [April 17, 2024, 1:12pm UTC](https://forum.social.plus/t/getuserunread/1266/2 "2024-04-17T13:12:54Z")

</div>

Hello, may I know your sdk version as well, please?

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 17, 2024, 1:23pm UTC](https://forum.social.plus/t/getuserunread/1266/3 "2024-04-17T13:23:23Z")

</div>

Hi there,

Sure… SDK version is 6.21.0 Thanks!

---

<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:** [April 17, 2024, 1:32pm UTC](https://forum.social.plus/t/getuserunread/1266/4 "2024-04-17T13:32:17Z")

</div>

Thank you, we will pass it to the team to further check. Will keep you posted on the updates.

---

<div class="post-metadata">

**Author:** ![topAmity](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@topAmity](https://forum.social.plus/u/topAmity)\
**Post date:** [April 18, 2024, 10:11am UTC](https://forum.social.plus/t/getuserunread/1266/5 "2024-04-18T10:11:59Z")

</div>

Hi, I still can’t reproduce this issue. May I ask have you already call `Client.enableUnreadCount();` after you call login SDK?

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 18, 2024, 10:31am UTC](https://forum.social.plus/t/getuserunread/1266/6 "2024-04-18T10:31:16Z")

</div>

Hi there,

Yes we do call that.

Let me try and reproduce in a fresh environment.

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 18, 2024, 11:14am UTC](https://forum.social.plus/t/getuserunread/1266/7 "2024-04-18T11:14:02Z")

</div>

Hi there,

Have just reproduced in very basic POC environment.

1.Create channel.  
2.Create subchannel.  
3. Log in.  
4. Send message.

Logged in user sends message to conversation subchannel.  
getUserUnread() for logged in user shows the users own message as “unread”.

Could you share with me the env you have used to reproduce and see if I have missed anything?

Thanks.

---

<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:** [April 19, 2024, 10:42am UTC](https://forum.social.plus/t/getuserunread/1266/8 "2024-04-19T10:42:01Z")

</div>

Hello, please refer to this sample project: [GitHub - AmityCo/Amity-Chat-UIKit-React-Native-OpenSource: Amity Social Cloud offers Chat and Social SDKs to streamline app development. Dive into our UI Kits and sample apps in our repositories to spark your creativity. To learn more, visit amity.co.](https://github.com/AmityCo/Amity-Chat-UIKit-React-Native-OpenSource)

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 19, 2024, 10:58am UTC](https://forum.social.plus/t/getuserunread/1266/9 "2024-04-19T10:58:33Z")

</div>

Hi,

That project makes no use of getUserUnread() and just uses unreadCount property of the channel?

I have the same issues when I try to use unreadCount on the subchannel and channel.

Also, is a react native app which is not what I’m using. Just using typescript in a basic react app.

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 19, 2024, 11:04am UTC](https://forum.social.plus/t/getuserunread/1266/10 "2024-04-19T11:04:02Z")

</div>

amityco/ts-sdk: 6.21.0

---

<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:** [April 19, 2024, 12:28pm UTC](https://forum.social.plus/t/getuserunread/1266/11 "2024-04-19T12:28:59Z")

</div>

When you call _getUserUnread_ , did you use the same userId to log in?

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 19, 2024, 1:33pm UTC](https://forum.social.plus/t/getuserunread/1266/12 "2024-04-19T13:33:42Z")

</div>

Yes. We are using the same user account when we call getUserUnread.

If is worth noting that if you can mark the message as read but there is then a period of time in between the unread message being detected and it then being marked as read which is jarring for the user.

Can I confirm that default behaviour is that logged in users own messages are not initially classed as unread from the perspective of the sending user?

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [April 25, 2024, 5:25pm UTC](https://forum.social.plus/t/getuserunread/1266/13 "2024-04-25T17:25:43Z")

</div>

Hi there, has there been any update on this?

---

<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:** [April 26, 2024, 7:43am UTC](https://forum.social.plus/t/getuserunread/1266/14 "2024-04-26T07:43:36Z")

</div>

Hello @skullicious , We have addressed the issue you reported in version 6.23.0. Please check again, and if the problem persists, feel free to notify us.

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [May 1, 2024, 2:02pm UTC](https://forum.social.plus/t/getuserunread/1266/15 "2024-05-01T14:02:38Z")

</div>

Hi there, I have checked and I am still experiencing the same issue with version 6.23.0.  
Do you have a working example of this I can reference? Thanks.

---

<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 2, 2024, 8:18am UTC](https://forum.social.plus/t/getuserunread/1266/16 "2024-05-02T08:18:43Z")

</div>

@skullicious Could you kindly check the `/api/v1/markers/sync` endpoint to see if the `unreadCount` in `userMarker` has increased?

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [May 3, 2024, 10:16am UTC](https://forum.social.plus/t/getuserunread/1266/17 "2024-05-03T10:16:04Z")

</div>

When I send a message I don’t need any calls to that endpoint.  
If I refresh the page I see calls to it but it shows the message (ie 1) before clearing it with MarkRead()…  
I see no further calls to it after that point.

---

<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 3, 2024, 11:31am UTC](https://forum.social.plus/t/getuserunread/1266/18 "2024-05-03T11:31:40Z")

</div>

@skullicious Thank you for checking. I’ll pass this along to the team and get back to you if we have any further 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:** [May 7, 2024, 2:45pm UTC](https://forum.social.plus/t/getuserunread/1266/19 "2024-05-07T14:45:49Z")

</div>

Hello @skullicious Due to the issue you’re experiencing, we would like to request additional details in the form of a **HAR file** that documents the problem you encountered for further investigation.

Please send it to the following **email: [support.asc@amity.co](mailto:support.asc@amity.co)** , Once you have sent the information, please let us know.

---

<div class="post-metadata">

**Author:** ![skullicious](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@skullicious](https://forum.social.plus/u/skullicious)\
**Post date:** [May 8, 2024, 9:56am UTC](https://forum.social.plus/t/getuserunread/1266/20 "2024-05-08T09:56:37Z")

</div>

Sorry, what is a HAR file?

[Next page](https://forum.social.plus/t/getuserunread/1266.md?page=2)
