You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
8 years ago
|
import { connect } from 'react-redux';
|
||
|
import { makeGetAccount } from '../selectors';
|
||
|
import Account from '../components/account';
|
||
8 years ago
|
import {
|
||
|
followAccount,
|
||
8 years ago
|
unfollowAccount,
|
||
|
blockAccount,
|
||
8 years ago
|
unblockAccount,
|
||
|
muteAccount,
|
||
|
unmuteAccount,
|
||
8 years ago
|
} from '../actions/accounts';
|
||
8 years ago
|
|
||
|
const makeMapStateToProps = () => {
|
||
|
const getAccount = makeGetAccount();
|
||
|
|
||
|
const mapStateToProps = (state, props) => ({
|
||
|
account: getAccount(state, props.id),
|
||
8 years ago
|
me: state.getIn(['meta', 'me'])
|
||
8 years ago
|
});
|
||
|
|
||
|
return mapStateToProps;
|
||
|
};
|
||
|
|
||
|
const mapDispatchToProps = (dispatch) => ({
|
||
8 years ago
|
onFollow (account) {
|
||
|
if (account.getIn(['relationship', 'following'])) {
|
||
|
dispatch(unfollowAccount(account.get('id')));
|
||
|
} else {
|
||
|
dispatch(followAccount(account.get('id')));
|
||
|
}
|
||
8 years ago
|
},
|
||
|
|
||
|
onBlock (account) {
|
||
|
if (account.getIn(['relationship', 'blocking'])) {
|
||
|
dispatch(unblockAccount(account.get('id')));
|
||
|
} else {
|
||
|
dispatch(blockAccount(account.get('id')));
|
||
|
}
|
||
8 years ago
|
},
|
||
|
|
||
|
onMute (account) {
|
||
|
if (account.getIn(['relationship', 'muting'])) {
|
||
|
dispatch(unmuteAccount(account.get('id')));
|
||
|
} else {
|
||
|
dispatch(muteAccount(account.get('id')));
|
||
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
});
|
||
|
|
||
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Account);
|