From e505577abf64e1a879e834619668cebe839eb190 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 15 Feb 2017 21:06:13 -0500 Subject: Clean-up unread counting and fix commenting (#5437) --- webapp/stores/channel_store.jsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'webapp') diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index ab015d434..6a012c600 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -9,6 +9,7 @@ import UserStore from 'stores/user_store.jsx'; var Utils; import {ActionTypes, Constants} from 'utils/constants.jsx'; +import {isSystemMessage} from 'utils/post_utils.jsx'; const NotificationPrefs = Constants.NotificationPrefs; const PostTypes = Constants.PostTypes; @@ -510,13 +511,17 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { return; } + if (action.post.user_id === UserStore.getCurrentId() && !isSystemMessage(action.post)) { + return; + } + var id = action.post.channel_id; var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : null; + var markRead = id === ChannelStore.getCurrentId() && window.isActive; - // Current team and not current channel or the window is inactive - if ((TeamStore.getCurrentId() === teamId || teamId === '') && (ChannelStore.getCurrentId() !== id || !window.isActive)) { - ChannelStore.incrementMessages(id, action.post.user_id === UserStore.getCurrentId()); + if (TeamStore.getCurrentId() === teamId || teamId === '') { ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps); + ChannelStore.incrementMessages(id, markRead); ChannelStore.emitChange(); } break; @@ -526,6 +531,11 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { ChannelStore.emitChange(); break; + case ActionTypes.CREATE_COMMENT: + ChannelStore.incrementMessages(action.post.channel_id, true); + ChannelStore.emitChange(); + break; + default: break; } -- cgit v1.2.3-1-g7c22