Skip to content

Commit

Permalink
fix: align unread counting on muted channel (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Mar 28, 2024
1 parent 946362f commit 1f1934b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
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 */
currentMutedChannelIds.forEach((cid) => {
if (!nextMutedChannelIds.includes(cid) && this.activeChannels[cid]) {
this.activeChannels[cid].state.unreadCount = 0;
}
});

this.mutedChannels = event.me.channel_mutes;
}

Expand Down

0 comments on commit 1f1934b

Please sign in to comment.