From 38b16b435f71e27fba0d8b0036d62165a8ee3bbb Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 14 Apr 2018 01:30:49 +0800 Subject: [PATCH] [MM-10055] Filter out deactivated user when viewing channel members (#1582) * filter out deactivated user when viewing channel members * apply makeGetProfilesInChannel is filtering out the deactivated user/s * update using makeMapStateToProps --- .../channel_members/channel_members.js | 2 +- app/screens/channel_members/index.js | 34 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/screens/channel_members/channel_members.js b/app/screens/channel_members/channel_members.js index f9bc65389..4d73e818e 100644 --- a/app/screens/channel_members/channel_members.js +++ b/app/screens/channel_members/channel_members.js @@ -28,7 +28,7 @@ class ChannelMembers extends PureComponent { intl: intlShape.isRequired, theme: PropTypes.object.isRequired, currentChannel: PropTypes.object, - currentChannelMembers: PropTypes.array.isRequired, + currentChannelMembers: PropTypes.array, currentUserId: PropTypes.string.isRequired, navigator: PropTypes.object, requestStatus: PropTypes.string, diff --git a/app/screens/channel_members/index.js b/app/screens/channel_members/index.js index 602b07f2c..163abce0a 100644 --- a/app/screens/channel_members/index.js +++ b/app/screens/channel_members/index.js @@ -7,21 +7,31 @@ import {connect} from 'react-redux'; import {handleRemoveChannelMembers} from 'app/actions/views/channel_members'; import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentChannel, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels'; -import {getProfilesInCurrentChannel} from 'mattermost-redux/selectors/entities/users'; +import {makeGetProfilesInChannel} from 'mattermost-redux/selectors/entities/users'; import {getProfilesInChannel, searchProfiles} from 'mattermost-redux/actions/users'; import ChannelMembers from './channel_members'; -function mapStateToProps(state) { - return { - theme: getTheme(state), - currentChannel: getCurrentChannel(state) || {}, - currentChannelMembers: getProfilesInCurrentChannel(state), - currentUserId: state.entities.users.currentUserId, - requestStatus: state.requests.users.getProfilesInChannel.status, - searchRequestStatus: state.requests.users.searchProfiles.status, - removeMembersStatus: state.requests.channels.removeChannelMember.status, - canManageUsers: canManageChannelMembers(state), +function makeMapStateToProps() { + const getChannelMembers = makeGetProfilesInChannel(); + + return (state) => { + const currentChannel = getCurrentChannel(state) || {}; + let currentChannelMembers = []; + if (currentChannel) { + currentChannelMembers = getChannelMembers(state, currentChannel.id, true); + } + + return { + theme: getTheme(state), + currentChannel, + currentChannelMembers, + currentUserId: state.entities.users.currentUserId, + requestStatus: state.requests.users.getProfilesInChannel.status, + searchRequestStatus: state.requests.users.searchProfiles.status, + removeMembersStatus: state.requests.channels.removeChannelMember.status, + canManageUsers: canManageChannelMembers(state), + }; }; } @@ -35,4 +45,4 @@ function mapDispatchToProps(dispatch) { }; } -export default connect(mapStateToProps, mapDispatchToProps)(ChannelMembers); +export default connect(makeMapStateToProps, mapDispatchToProps)(ChannelMembers);