Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Fix markChannelAsRead on login (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum authored and hmhealey committed Aug 28, 2020
1 parent d1b7285 commit c96ce5e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/mattermost-redux/src/actions/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,14 +925,16 @@ export function markChannelAsRead(channelId, prevChannelId) {
const channel = channelState.channels[channelId];
const prevChannel = channelState.channels[prevChannelId]; // May be null since prevChannelId is optional

actions.push({
type: ChannelTypes.RECEIVED_MSG_AND_MENTION_COUNT,
data: {
channel_id: channelId,
msg_count: channel.total_msg_count,
mention_count: 0
}
});
if (channel) {
actions.push({
type: ChannelTypes.RECEIVED_MSG_AND_MENTION_COUNT,
data: {
channel_id: channelId,
msg_count: channel.total_msg_count,
mention_count: 0
}
});
}

if (prevChannel && channelId !== prevChannelId) {
actions.push({
Expand All @@ -951,7 +953,7 @@ export function markChannelAsRead(channelId, prevChannelId) {

const teamUnreads = [];

if (channel.team_id) {
if (channel && channel.team_id) {
const teamMember = teamState.myMembers[channel.team_id];

// Decrement mention_count and msg_count by the number that was read in the channel.
Expand All @@ -970,7 +972,7 @@ export function markChannelAsRead(channelId, prevChannelId) {
teamUnreads.push(teamUnread);
}

if (prevChannel && prevChannel.team_id && channel.team_id !== prevChannel.team_id) {
if (channel && prevChannel && prevChannel.team_id && channel.team_id !== prevChannel.team_id) {
const prevTeamMember = teamState.myMembers[prevChannel.team_id];

teamUnreads.push({
Expand Down

0 comments on commit c96ce5e

Please sign in to comment.