summaryrefslogtreecommitdiffstats
path: root/webapp/stores/channel_store.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/stores/channel_store.jsx')
-rw-r--r--webapp/stores/channel_store.jsx37
1 files changed, 37 insertions, 0 deletions
diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx
index 575f68f4c..488e49492 100644
--- a/webapp/stores/channel_store.jsx
+++ b/webapp/stores/channel_store.jsx
@@ -392,6 +392,31 @@ class ChannelStoreClass extends EventEmitter {
return false;
}
+
+ incrementMessages(id) {
+ if (!this.unreadCounts[id]) {
+ return;
+ }
+
+ this.unreadCounts[id].msgs++;
+ this.get(id).total_msg_count++;
+ }
+
+ incrementMentionsIfNeeded(id, msgProps) {
+ let mentions = [];
+ if (msgProps && msgProps.mentions) {
+ mentions = JSON.parse(msgProps.mentions);
+ }
+
+ if (!this.unreadCounts[id]) {
+ return;
+ }
+
+ if (mentions.indexOf(UserStore.getCurrentId()) !== -1) {
+ this.unreadCounts[id].mentions++;
+ this.getMyMember(id).mention_count++;
+ }
+ }
}
var ChannelStore = new ChannelStoreClass();
@@ -469,6 +494,18 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {
ChannelStore.emitStatsChange();
break;
+ case ActionTypes.RECEIVED_POST:
+ var id = action.post.channel_id;
+ var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : '';
+
+ // Current team and not current channel or the window is inactive
+ if (TeamStore.getCurrentId() === teamId && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
+ ChannelStore.incrementMessages(id);
+ ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
+ ChannelStore.emitChange();
+ }
+ break;
+
default:
break;
}