-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
room.getUnreadNotificationCount() always return undefined #997
Comments
Share your code. Without seeing how you set up the state of the js-sdk its impossible to help you |
I'm trying to implement notifications when user has unread messages at rooms. What can be a reason ? |
Share your code. It depends on the various stores and sync mechanisms you are using. |
|
any suggestions ? |
I was also experiencing the same problem like @LuLongSH and I looked at the source code and realized that it returns undefined because it doesn't automatically record how many messages the receiver has missed. It's necessary to set the notifications first. Suppose I know based on the timeline history there were 3 more messages I missed after I sent a message, then I would set it like so, Then when you set the number of missed messages you are able to get how many unread messages there are by calling To know how many messages were missed, I looked at the Mine could be a lil hacky, I hope this helps |
i tried to set unread msg count to zero after reading msgs ,but when i refresh that page and call room.getUnreadNotification , than it will remain same |
@dhaval-t-simform you should be sending a read receipt so zero it out on the server, rather than just clobbering the value locally |
@t3chguy |
@t3chguy |
http://matrix-org.github.io/matrix-js-sdk/stable/classes/MatrixClient.html#sendReadReceipt
https://spec.matrix.org/v1.7/client-server-api/#receipts
Depends on your push rules, the notification counts are counts of unread events which when evaluated in your push rules result in a |
@t3chguy What I've observed is on reload or re-login its room.notificationCounts.total gets to the previous count which I want to update on server as you already mentioned. Basically I just want to manage the unread notification count(where in I'm using getUnreadNotificationCount()) and on opening the respective chat I want to update the count to 0 or accordingly on the server as you said. Any help will be very helpful. |
You can't just update the server count to a specific number, you have to move the read receipt to a given event, so your server knows up to which point you have read and based on that it'll calculate your unreads. So if you want to update it to zero, pass in the ID of the very latest event that happened in the timeline of the room. |
@t3chguy |
I suggest https://matrix.to/#/#matrix-dev:matrix.org - this is an issue tracker, not a support forum |
Hello @t3chguy The upper issue is resolved using but after reading the unread messages the count gets 0 but on refreshing the page on the UI it still shows the last unread message count while on second refresh it shows 0. I've asked the same in channel as well but didn't get any solution. |
Hello @t3chguy Can we send read receipts in thread? As I am not able to fix unread notification count for threads. |
@dhaval-t-simform yes, as per the Matrix spec, read receipts can be sent in a thread to events other than the thread root. |
@t3chguy |
Indeed those methods, seems like you are passing the wrong object. You have to pass the MatrixEvent of the reply in the thread you wish to send an RR to. http://matrix-org.github.io/matrix-js-sdk/stable/classes/MatrixClient.html#sendReadReceipt |
@t3chguy |
No, as I said before
Threads are a container of multiple events, they have their own timeline, you read messages not entire rooms/threads. |
I suggest #matrix-dev:matrix.org for any future help, this isn't a support forum. |
@t3chguy |
|
I want to get unread chat messages count (total or one room),but haven't find the right function.
The text was updated successfully, but these errors were encountered: