-
Notifications
You must be signed in to change notification settings - Fork 77
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
Updating countUnread function #452
Conversation
Size Change: +1.05 kB (0%) Total Size: 196 kB
|
3bdafbf
to
0f5ed75
Compare
@@ -1097,16 +1097,17 @@ export class Channel< | |||
} | |||
|
|||
/** | |||
* countUnread - Count the number of messages with a date thats newer than the last read timestamp | |||
* countUnread - Count of unread messages | |||
* | |||
* @param {Date | Immutable.ImmutableDate | null} [lastRead] lastRead the time that the user read a message, defaults to current user's read state | |||
* | |||
* @return {number} Unread count | |||
*/ | |||
countUnread(lastRead?: Date | Immutable.ImmutableDate | null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countUnread
function fails to return actual count of unread messages if [number of unread messages] > [number of messages loaded/queried in channel]. E.g., if user queries only first page of channel messages and user has 100 unread messages ---> channel.countUnread()
will return only 25.
@@ -1462,6 +1464,10 @@ export class Channel< | |||
event.user.id, | |||
Immutable({ user: { ...event.user }, last_read: event.received_at }), | |||
); | |||
|
|||
if (event.user?.id === this.getClient().user?.id) { | |||
s.unreadCount = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set to 0 message.read
event.
fixes #336