PLT-3754 EE: Add a Display Option to disable Join/Leave messages (#3808)

* PLT-3754 EE: Add a Display Option to disable Join/Leave messages

* Differentiate between join/leave add/remove messages

* Update user removed from channel text message
This commit is contained in:
enahum
2016-08-18 17:37:55 -05:00
committed by Corey Hulen
parent 4a2fbcaf98
commit ed6b69aab3
9 changed files with 193 additions and 37 deletions

View File

@@ -6,6 +6,7 @@ import EventEmitter from 'events';
import Constants from 'utils/constants.jsx';
import UserStore from './user_store.jsx';
import ChannelStore from './channel_store.jsx';
import PreferenceStore from './preference_store.jsx';
import * as Utils from 'utils/utils.jsx';
import * as PostUtils from 'utils/post_utils.jsx';
const ActionTypes = Constants.ActionTypes;
@@ -28,7 +29,9 @@ class NotificationStoreClass extends EventEmitter {
handleRecievedPost(post, msgProps) {
// Send desktop notification
if ((UserStore.getCurrentId() !== post.user_id || post.props.from_webhook === 'true')) {
if (PostUtils.isSystemMessage(post) && post.type !== 'system_join_leave') {
if (PostUtils.isSystemMessage(post)) {
return;
} else if (!PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'join_leave', true) && post.type === Constants.POST_TYPE_JOIN_LEAVE) {
return;
}

View File

@@ -548,6 +548,24 @@ class PostStoreClass extends EventEmitter {
return commentCount;
}
filterPosts(channelId, joinLeave) {
const postsList = JSON.parse(JSON.stringify(this.getVisiblePosts(channelId)));
if (!joinLeave && postsList) {
postsList.order = postsList.order.filter((id) => {
if (postsList.posts[id].type === Constants.POST_TYPE_JOIN_LEAVE) {
Reflect.deleteProperty(postsList.posts, id);
return false;
}
return true;
});
}
return postsList;
}
}
var PostStore = new PostStoreClass();