The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

31 lines
771 B

  1. import { connect } from 'react-redux';
  2. import { makeGetAccount } from '../selectors';
  3. import Account from '../components/account';
  4. import {
  5. followAccount,
  6. unfollowAccount
  7. } from '../actions/accounts';
  8. const makeMapStateToProps = () => {
  9. const getAccount = makeGetAccount();
  10. const mapStateToProps = (state, props) => ({
  11. account: getAccount(state, props.id),
  12. me: state.getIn(['meta', 'me'])
  13. });
  14. return mapStateToProps;
  15. };
  16. const mapDispatchToProps = (dispatch) => ({
  17. onFollow (account) {
  18. if (account.getIn(['relationship', 'following'])) {
  19. dispatch(unfollowAccount(account.get('id')));
  20. } else {
  21. dispatch(followAccount(account.get('id')));
  22. }
  23. }
  24. });
  25. export default connect(makeMapStateToProps, mapDispatchToProps)(Account);