This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2016-10-27 21:59:56 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { makeGetAccount } from '../../../selectors';
|
|
|
|
import Account from '../components/account';
|
2016-10-28 20:05:44 +02:00
|
|
|
import {
|
|
|
|
followAccount,
|
|
|
|
unfollowAccount
|
|
|
|
} from '../../../actions/accounts';
|
2016-10-27 21:59:56 +02:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
account: getAccount(state, props.id),
|
|
|
|
me: state.getIn(['timelines', 'me'])
|
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2016-10-28 20:05:44 +02:00
|
|
|
onFollow (account) {
|
|
|
|
if (account.getIn(['relationship', 'following'])) {
|
|
|
|
dispatch(unfollowAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(followAccount(account.get('id')));
|
|
|
|
}
|
|
|
|
}
|
2016-10-27 21:59:56 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(makeMapStateToProps, mapDispatchToProps)(Account);
|