]> cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/containers/account_container.js
Improve eslint rules (#3147)
[mastodon.git] / app / javascript / mastodon / containers / account_container.js
1 import { connect } from 'react-redux';
2 import { makeGetAccount } from '../selectors';
3 import Account from '../components/account';
4 import {
5 followAccount,
6 unfollowAccount,
7 blockAccount,
8 unblockAccount,
9 muteAccount,
10 unmuteAccount,
11 } from '../actions/accounts';
12
13 const makeMapStateToProps = () => {
14 const getAccount = makeGetAccount();
15
16 const mapStateToProps = (state, props) => ({
17 account: getAccount(state, props.id),
18 me: state.getIn(['meta', 'me']),
19 });
20
21 return mapStateToProps;
22 };
23
24 const mapDispatchToProps = (dispatch) => ({
25 onFollow (account) {
26 if (account.getIn(['relationship', 'following'])) {
27 dispatch(unfollowAccount(account.get('id')));
28 } else {
29 dispatch(followAccount(account.get('id')));
30 }
31 },
32
33 onBlock (account) {
34 if (account.getIn(['relationship', 'blocking'])) {
35 dispatch(unblockAccount(account.get('id')));
36 } else {
37 dispatch(blockAccount(account.get('id')));
38 }
39 },
40
41 onMute (account) {
42 if (account.getIn(['relationship', 'muting'])) {
43 dispatch(unmuteAccount(account.get('id')));
44 } else {
45 dispatch(muteAccount(account.get('id')));
46 }
47 },
48 });
49
50 export default connect(makeMapStateToProps, mapDispatchToProps)(Account);
This page took 0.080943 seconds and 5 git commands to generate.