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.
const handleMarkChannelAsRead = (subChannelId: string) => {
//Async?
const messagesByChannel = messages.filter(
(msg) => msg.subChannelId === subChannelId
)
messagesByChannel.map((msg) => msg.markRead())
}
useEffect(() => {
if (isConnected) {
const handleLiveObject = (
liveObject: Amity.LiveObject<Amity.UserUnread | undefined>
) => {
if (liveObject.data) {
const { unreadCount } = liveObject.data
setUserUnreadCount(unreadCount)
}
}
AmityClient.getUserUnread(handleLiveObject)
}
}, [isConnected])
Hello, may I know your sdk version as well, please?
Hi there,
Sure… SDK version is 6.21.0 Thanks!
Thank you, we will pass it to the team to further check. Will keep you posted on the updates.
1 Like
Hi, I still can’t reproduce this issue. May I ask have you already call Client.enableUnreadCount();
after you call login SDK?
Hi there,
Yes we do call that.
Let me try and reproduce in a fresh environment.
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.
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.
When you call getUserUnread , did you use the same userId to log in?
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?
Hi there, has there been any update on this?
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.
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.
@skullicious Could you kindly check the /api/v1/markers/sync
endpoint to see if the unreadCount
in userMarker
has increased?
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.
@skullicious Thank you for checking. I’ll pass this along to the team and get back to you if we have any further updates.
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 , Once you have sent the information, please let us know.
Sorry, what is a HAR file?