diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-02-14 15:55:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-14 15:55:35 -0500 |
commit | b86e0daf83c8b7d42f06dcc975542c28fe9ecc69 (patch) | |
tree | db625778d006d88724a43ed6b13477d77efbb207 | |
parent | 86a92f8c7571b5770eee38225465a85b5d9de9b8 (diff) | |
download | chat-b86e0daf83c8b7d42f06dcc975542c28fe9ecc69.tar.gz chat-b86e0daf83c8b7d42f06dcc975542c28fe9ecc69.tar.bz2 chat-b86e0daf83c8b7d42f06dcc975542c28fe9ecc69.zip |
Fix commenting in RHS marking channel unread (#5405)
-rw-r--r-- | webapp/stores/channel_store.jsx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index b82be650e..ab015d434 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -394,7 +394,7 @@ class ChannelStoreClass extends EventEmitter { return false; } - incrementMessages(id) { + incrementMessages(id, markRead = false) { if (!this.unreadCounts[id]) { return; } @@ -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) { @@ -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: |