-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
index.js
47 lines (38 loc) · 1.44 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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
import {getStatusesByIdsBatchedDebounced} from 'mattermost-redux/actions/users';
import {getCurrentUserId, getStatusForUserId, getUser} from 'mattermost-redux/selectors/entities/users';
import {setProfileImageUri} from 'app/actions/views/edit_profile';
import {getProfileImageUri} from 'app/selectors/views';
import ProfilePicture from './profile_picture';
function mapStateToProps(state, ownProps) {
let status = ownProps.status;
const user = getUser(state, ownProps.userId);
if (!status && ownProps.userId) {
status = getStatusForUserId(state, ownProps.userId);
}
const isCurrentUser = getCurrentUserId(state) === ownProps.userId;
let profileImageUri = '';
if (isCurrentUser) {
profileImageUri = getProfileImageUri(state);
}
return {
isCurrentUser,
theme: getTheme(state),
profileImageUri,
status,
user,
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
setProfileImageUri,
getStatusForId: getStatusesByIdsBatchedDebounced,
}, dispatch),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(ProfilePicture);