diff --git a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.test.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.test.ts index 1d9679e5ae..a9357a57ba 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.test.ts @@ -2255,6 +2255,35 @@ describe('Selectors.Channels.getUnreadStatus', () => { expect(Selectors.getUnreadStatus(newState)).toBe(1); }); + + it('should not count unreads and mentions from a muted channel', () => { + const mutedChannelId = channel2.id; + const newMyMembers = { + ...testState.entities.channels.myMembers, + [mutedChannelId]: { + ...testState.entities.channels.myMembers[mutedChannelId], + notify_props: { + ...testState.entities.channels.myMembers[mutedChannelId].notify_props, + mark_unread: 'mention', + }, + mention_count: 3, + msg_count: 10, + }, + }; + + const newState = { + ...testState, + entities: { + ...testState.entities, + channels: { + ...testState.entities.channels, + myMembers: newMyMembers, + }, + }, + }; + + expect(Selectors.getUnreadStatus(newState)).toBe(1); + }); }); describe('Selectors.Channels.getUnreadStatus', () => { diff --git a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.ts index 51ee4f4e13..62d36fc5ed 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/channels.ts @@ -642,8 +642,12 @@ export const getUnreadStatus: (state: GlobalState) => BasicUnreadStatus = create return counts; } + if (isChannelMuted(membership)) { + return counts; + } + const mentions = collapsedThreads ? membership.mention_count_root : membership.mention_count; - if (mentions && !isChannelMuted(membership)) { + if (mentions) { counts.mentions += mentions; }