summaryrefslogtreecommitdiffstats
path: root/webapp/components/status_dropdown/index.jsx
blob: e200b2e347db530a29d56ff1027622a24f459ba1 (plain)
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
import {setStatus} from 'mattermost-redux/actions/users';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {
    getCurrentUser,
    getStatusForUserId
} from 'mattermost-redux/selectors/entities/users';
import {Client4} from 'mattermost-redux/client';

import StatusDropdown from 'components/status_dropdown/status_dropdown.jsx';

function mapStateToProps(state) {
    const currentUser = getCurrentUser(state);
    const userId = currentUser.id;
    const lastPicUpdate = currentUser.last_picture_update;
    const profilePicture = Client4.getProfilePictureUrl(userId, lastPicUpdate);
    const status = getStatusForUserId(state, currentUser.id);
    return {
        userId,
        profilePicture,
        status
    };
}

function mapDispatchToProps(dispatch) {
    return {
        actions: bindActionCreators({
            setStatus
        }, dispatch)
    };
}

export default connect(mapStateToProps, mapDispatchToProps)(StatusDropdown);