Clean-up unread counting and fix commenting (#5437)

Этот коммит содержится в:
Joram Wilander
2017-02-15 21:06:13 -05:00
коммит произвёл Corey Hulen
родитель 01a8114aa3
Коммит e505577abf

Просмотреть файл

@@ -9,6 +9,7 @@ import UserStore from 'stores/user_store.jsx';
var Utils; var Utils;
import {ActionTypes, Constants} from 'utils/constants.jsx'; import {ActionTypes, Constants} from 'utils/constants.jsx';
import {isSystemMessage} from 'utils/post_utils.jsx';
const NotificationPrefs = Constants.NotificationPrefs; const NotificationPrefs = Constants.NotificationPrefs;
const PostTypes = Constants.PostTypes; const PostTypes = Constants.PostTypes;
@@ -510,13 +511,17 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
return; return;
} }
if (action.post.user_id === UserStore.getCurrentId() && !isSystemMessage(action.post)) {
return;
}
var id = action.post.channel_id; var id = action.post.channel_id;
var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : null; 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 === '') {
if ((TeamStore.getCurrentId() === teamId || teamId === '') && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
ChannelStore.incrementMessages(id, action.post.user_id === UserStore.getCurrentId());
ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps); ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
ChannelStore.incrementMessages(id, markRead);
ChannelStore.emitChange(); ChannelStore.emitChange();
} }
break; break;
@@ -526,6 +531,11 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.emitChange(); ChannelStore.emitChange();
break; break;
case ActionTypes.CREATE_COMMENT:
ChannelStore.incrementMessages(action.post.channel_id, true);
ChannelStore.emitChange();
break;
default: default:
break; break;
} }