From 422abe4cb71166342ab35dc626496dc6d85e5f6e Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Wed, 12 Jul 2017 13:27:34 -0600 Subject: [PATCH] Fix undefined object issue in Jump to Conversation (#736) --- .../channels_list/filtered_list/filtered_list.js | 8 ++++++++ .../channels_list/filtered_list/index.js | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js b/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js index 58670b4a5..4a51cc2a5 100644 --- a/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js +++ b/app/components/channel_drawer/channels_list/filtered_list/filtered_list.js @@ -25,6 +25,7 @@ import ChannelDrawerItem from 'app/components/channel_drawer/channels_list/chann class FilteredList extends Component { static propTypes = { actions: PropTypes.shape({ + getProfilesInTeam: PropTypes.func.isRequired, makeGroupMessageVisibleIfNecessary: PropTypes.func.isRequired, searchChannels: PropTypes.func.isRequired, searchProfiles: PropTypes.func.isRequired @@ -44,6 +45,7 @@ class FilteredList extends Component { ), searchOrder: PropTypes.array.isRequired, pastDirectMessages: PropTypes.array, + restrictDms: PropTypes.bool.isRequired, statuses: PropTypes.object, styles: PropTypes.object.isRequired, term: PropTypes.string, @@ -63,6 +65,12 @@ class FilteredList extends Component { }; } + componentDidMount() { + if (this.props.restrictDms) { + this.props.actions.getProfilesInTeam(this.props.currentTeam.id); + } + } + shouldComponentUpdate(nextProps, nextState) { return !deepEqual(this.props, nextProps, {strict: true}) || !deepEqual(this.state, nextState, {strict: true}); } diff --git a/app/components/channel_drawer/channels_list/filtered_list/index.js b/app/components/channel_drawer/channels_list/filtered_list/index.js index 3703e4d04..f2beebc7e 100644 --- a/app/components/channel_drawer/channels_list/filtered_list/index.js +++ b/app/components/channel_drawer/channels_list/filtered_list/index.js @@ -6,7 +6,7 @@ import {connect} from 'react-redux'; import {createSelector} from 'reselect'; import {searchChannels} from 'mattermost-redux/actions/channels'; -import {searchProfiles} from 'mattermost-redux/actions/users'; +import {getProfilesInTeam, searchProfiles} from 'mattermost-redux/actions/users'; import {makeGroupMessageVisibleIfNecessary} from 'mattermost-redux/actions/preferences'; import {General} from 'mattermost-redux/constants'; import {getGroupChannels, getOtherChannels} from 'mattermost-redux/selectors/entities/channels'; @@ -29,10 +29,11 @@ function mapStateToProps(state, ownProps) { const {currentUserId} = state.entities.users; let profiles; - if (getConfig(state).RestrictDirectMessage === General.RESTRICT_DIRECT_MESSAGE_ANY) { - profiles = getUsers(state); - } else { + const restrictDms = getConfig(state).RestrictDirectMessage !== General.RESTRICT_DIRECT_MESSAGE_ANY; + if (restrictDms) { profiles = getProfilesInCurrentTeam(state); + } else { + profiles = getUsers(state); } const searchOrder = Config.DrawerSearchOrder ? Config.DrawerSearchOrder : DEFAULT_SEARCH_ORDER; @@ -46,6 +47,7 @@ function mapStateToProps(state, ownProps) { statuses: getUserStatuses(state), searchOrder, pastDirectMessages: pastDirectMessages(state), + restrictDms, ...ownProps }; } @@ -53,6 +55,7 @@ function mapStateToProps(state, ownProps) { function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ + getProfilesInTeam, makeGroupMessageVisibleIfNecessary, searchChannels, searchProfiles