forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (61 loc) · 2.34 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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 {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
import {getChannel} from 'mattermost-redux/selectors/entities/channels';
import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {scrollPostList} from 'actions/views/channel';
import {setRhsExpanded, showPinnedPosts} from 'actions/views/rhs';
import {
getIsRhsExpanded,
getIsRhsOpen,
getRhsState,
getSelectedPostId,
getSelectedPostCardId,
getSelectedChannelId,
getPreviousRhsState,
} from 'selectors/rhs';
import {RHSStates} from 'utils/constants.jsx';
import SidebarRight from './sidebar_right.jsx';
function mapStateToProps(state) {
const rhsState = getRhsState(state);
const channelId = getSelectedChannelId(state);
let channel = null;
if (channelId) {
channel = getChannel(state, channelId);
if (channel == null) {
// the permalink view is not really tied to a particular channel but still needs it
const {focusedPostId} = state.views.channel;
const post = getPost(state, focusedPostId);
// the post take some time before being available on page load
if (post != null) {
channel = getChannel(state, post.channel_id);
}
}
}
return {
isExpanded: getIsRhsExpanded(state),
isOpen: getIsRhsOpen(state),
channel,
currentUserId: getCurrentUserId(state),
postRightVisible: Boolean(getSelectedPostId(state)),
postCardVisible: Boolean(getSelectedPostCardId(state)),
searchVisible: Boolean(rhsState) && rhsState !== RHSStates.PLUGIN,
previousRhsState: getPreviousRhsState(state),
isMentionSearch: rhsState === RHSStates.MENTION,
isFlaggedPosts: rhsState === RHSStates.FLAG,
isPinnedPosts: rhsState === RHSStates.PIN,
isPluginView: rhsState === RHSStates.PLUGIN,
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
setRhsExpanded,
showPinnedPosts,
scrollPostList,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(SidebarRight);