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

fix: align unread counting on muted channel #1265

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
if (Array.isArray(this.data?.own_capabilities) && !this.data?.own_capabilities.includes('read-events'))
return false;

// FIXME: see #1265, adjust and count new messages even when the channel is muted
if (this.muteStatus().muted) return false;

return true;
Expand Down
13 changes: 0 additions & 13 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,19 +1261,6 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
}

if (event.type === 'notification.channel_mutes_updated' && event.me?.channel_mutes) {
const currentMutedChannelIds: string[] = [];
const nextMutedChannelIds: string[] = [];

this.mutedChannels.forEach((mute) => mute.channel && currentMutedChannelIds.push(mute.channel.cid));
event.me.channel_mutes.forEach((mute) => mute.channel && nextMutedChannelIds.push(mute.channel.cid));

/** Set the unread count of un-muted channels to 0, which is the behaviour of backend */
arnautov-anton marked this conversation as resolved.
Show resolved Hide resolved
currentMutedChannelIds.forEach((cid) => {
if (!nextMutedChannelIds.includes(cid) && this.activeChannels[cid]) {
this.activeChannels[cid].state.unreadCount = 0;
}
});

this.mutedChannels = event.me.channel_mutes;
}

Expand Down
Loading