Skip to content

Commit

Permalink
Fix commenting in RHS marking channel unread (#5405)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilander committed Feb 14, 2017
1 parent 86a92f8 commit b86e0da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions webapp/stores/channel_store.jsx
Expand Up @@ -394,7 +394,7 @@ class ChannelStoreClass extends EventEmitter {
return false;
}

incrementMessages(id) {
incrementMessages(id, markRead = false) {
if (!this.unreadCounts[id]) {
return;
}
Expand All @@ -404,8 +404,13 @@ class ChannelStoreClass extends EventEmitter {
return;
}

this.unreadCounts[id].msgs++;
this.get(id).total_msg_count++;

if (markRead) {
this.resetCounts(id);
} else {
this.unreadCounts[id].msgs++;
}
}

incrementMentionsIfNeeded(id, msgProps) {
Expand Down Expand Up @@ -510,14 +515,15 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {

// Current team and not current channel or the window is inactive
if ((TeamStore.getCurrentId() === teamId || teamId === '') && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
ChannelStore.incrementMessages(id);
ChannelStore.incrementMessages(id, action.post.user_id === UserStore.getCurrentId());
ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
ChannelStore.emitChange();
}
break;

case ActionTypes.CREATE_POST:
ChannelStore.incrementMessages(action.post.channel_id);
ChannelStore.incrementMessages(action.post.channel_id, true);
ChannelStore.emitChange();
break;

default:
Expand Down

0 comments on commit b86e0da

Please sign in to comment.