Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Fix ignore unread and DM unreads (#5391)
Browse files Browse the repository at this point in the history
* Fix ignoring unreads in channels

* Fix DM unreads
  • Loading branch information
jwilander committed Feb 13, 2017
1 parent c47b1e2 commit 656a316
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions stores/channel_store.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ class ChannelStoreClass extends EventEmitter {
return;
}

const member = this.getMyMember(id);
if (member && member.notify_props && member.notify_props.mark_unread === NotificationPrefs.MENTION) {
return;
}

this.unreadCounts[id].msgs++;
this.get(id).total_msg_count++;
}
Expand Down Expand Up @@ -496,10 +501,10 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => {

case ActionTypes.RECEIVED_POST:
var id = action.post.channel_id;
var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : '';
var teamId = action.websocketMessageProps ? action.websocketMessageProps.team_id : null;

// Current team and not current channel or the window is inactive
if (TeamStore.getCurrentId() === teamId && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
if ((TeamStore.getCurrentId() === teamId || teamId === '') && (ChannelStore.getCurrentId() !== id || !window.isActive)) {
ChannelStore.incrementMessages(id);
ChannelStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
ChannelStore.emitChange();
Expand Down
11 changes: 9 additions & 2 deletions stores/team_store.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import EventEmitter from 'events';
import UserStore from 'stores/user_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';

import Constants from 'utils/constants.jsx';
const NotificationPrefs = Constants.NotificationPrefs;
import {getSiteURL} from 'utils/url.jsx';
const ActionTypes = Constants.ActionTypes;

Expand Down Expand Up @@ -317,7 +319,12 @@ class TeamStoreClass extends EventEmitter {
}
}

incrementMessages(id) {
incrementMessages(id, channelId) {
const channelMember = ChannelStore.getMyMember(channelId);
if (channelMember && channelMember.notify_props && channelMember.notify_props.mark_unread === NotificationPrefs.MENTION) {
return;
}

const member = this.my_team_members.filter((m) => m.team_id === id)[0];
member.msg_count++;
}
Expand Down Expand Up @@ -390,7 +397,7 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
case ActionTypes.RECEIVED_POST:
var id = action.websocketMessageProps ? action.websocketMessageProps.team_id : '';
if (TeamStore.getCurrentId() !== id && id.length > 0) {
TeamStore.incrementMessages(id);
TeamStore.incrementMessages(id, action.post.channel_id);
TeamStore.incrementMentionsIfNeeded(id, action.websocketMessageProps);
TeamStore.emitChange();
}
Expand Down

0 comments on commit 656a316

Please sign in to comment.