Skip to content
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

Merged
merged 4 commits into from
Oct 7, 2020
Merged

Updating countUnread function #452

merged 4 commits into from
Oct 7, 2020

Conversation

vishalnarkhede
Copy link
Contributor

@vishalnarkhede vishalnarkhede commented Oct 1, 2020

fixes #336

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2020

Size Change: +1.05 kB (0%)

Total Size: 196 kB

Filename Size Change
dist/browser.es.js 41.6 kB +235 B (0%)
dist/browser.full-bundle.min.js 28.3 kB +113 B (0%)
dist/browser.js 42.2 kB +231 B (0%)
dist/index.es.js 41.6 kB +236 B (0%)
dist/index.js 42.2 kB +233 B (0%)

compressed-size-action

@vishalnarkhede vishalnarkhede changed the title Updating unreadCount function Updating countUnread function Oct 1, 2020
@@ -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) {
Copy link
Contributor Author

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;
Copy link
Contributor Author

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.

src/channel.ts Outdated Show resolved Hide resolved
src/channel.ts Outdated Show resolved Hide resolved
@mahboubii mahboubii merged commit a68c23e into master Oct 7, 2020
@delete-merged-branch delete-merged-branch bot deleted the vishal/unread-count-fix branch October 7, 2020 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get full channel's unread messages count
3 participants