45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {connect} from 'react-redux';
|
|
import {bindActionCreators} from 'redux';
|
|
|
|
import {addChannelMember} from 'mattermost-redux/actions/channels';
|
|
import {removePost} from 'mattermost-redux/actions/posts';
|
|
|
|
import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
|
import {getChannel} from 'mattermost-redux/selectors/entities/channels';
|
|
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
|
|
|
import {sendAddToChannelEphemeralPost} from 'app/actions/views/post';
|
|
|
|
import PostAddChannelMember from './post_add_channel_member';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const post = getPost(state, ownProps.postId) || {};
|
|
let channelType = '';
|
|
if (post && post.channel_id) {
|
|
const channel = getChannel(state, post.channel_id);
|
|
if (channel && channel.type) {
|
|
channelType = channel.type;
|
|
}
|
|
}
|
|
|
|
return {
|
|
channelType,
|
|
currentUser: getCurrentUser(state),
|
|
post,
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
actions: bindActionCreators({
|
|
addChannelMember,
|
|
removePost,
|
|
sendAddToChannelEphemeralPost,
|
|
}, dispatch),
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(PostAddChannelMember);
|