2016-11-20 13:39:18 -05:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { makeGetAccount } from '../selectors';
|
|
|
|
import Account from '../components/account';
|
2016-10-28 14:05:44 -04:00
|
|
|
import {
|
|
|
|
followAccount,
|
|
|
|
unfollowAccount
|
2016-11-20 13:39:18 -05:00
|
|
|
} from '../actions/accounts';
|
2016-10-27 15:59:56 -04:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
account: getAccount(state, props.id),
|
2016-10-30 10:06:43 -04:00
|
|
|
me: state.getIn(['meta', 'me'])
|
2016-10-27 15:59:56 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2016-10-28 14:05:44 -04:00
|
|
|
onFollow (account) {
|
|
|
|
if (account.getIn(['relationship', 'following'])) {
|
|
|
|
dispatch(unfollowAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(followAccount(account.get('id')));
|
|
|
|
}
|
|
|
|
}
|
2016-10-27 15:59:56 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Account);
|