-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix: channel unreadCount to be set as 0 when notification.mark_read event is dispatched [CRNS - 433] #914
Conversation
Size Change: +209 B (0%) Total Size: 285 kB
|
src/client.ts
Outdated
@@ -1184,6 +1184,11 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG | |||
this.mutedUsers = event.me.mutes; | |||
} | |||
|
|||
if (event.type === 'notification.mark_read') { | |||
const activeChannelKeys = Object.keys(this.activeChannels); | |||
activeChannelKeys.map((activeChannelKey) => (this.activeChannels[activeChannelKey].state.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.
Shouldn't this be .forEach(activeChannelKey =>
?
activeChannelKeys.map((activeChannelKey) => (this.activeChannels[activeChannelKey].state.unreadCount = 0)); | |
activeChannelKeys.forEach(activeChannelKey => this.activeChannels[activeChannelKey].state.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.
Yes, that's a better method to handle this case. Thanks, @peterdeme 😄
CLA
Description of the changes, What, Why, and How?
When we use the markAllRead method, we get the event notification.mark_read, which updates the total_unread_count, but not the channel.state.unreadCount. This PR solved the above issue.
Changelog