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.
 
 
 
 

51 lines
1.3 KiB

  1. import { connect } from 'react-redux';
  2. import { makeGetAccount } from '../../../selectors';
  3. import Header from '../components/header';
  4. import {
  5. followAccount,
  6. unfollowAccount,
  7. blockAccount,
  8. unblockAccount
  9. } from '../../../actions/accounts';
  10. import { mentionCompose } from '../../../actions/compose';
  11. import { initReport } from '../../../actions/reports';
  12. const makeMapStateToProps = () => {
  13. const getAccount = makeGetAccount();
  14. const mapStateToProps = (state, { accountId }) => ({
  15. account: getAccount(state, Number(accountId)),
  16. me: state.getIn(['meta', 'me'])
  17. });
  18. return mapStateToProps;
  19. };
  20. const mapDispatchToProps = dispatch => ({
  21. onFollow (account) {
  22. if (account.getIn(['relationship', 'following'])) {
  23. dispatch(unfollowAccount(account.get('id')));
  24. } else {
  25. dispatch(followAccount(account.get('id')));
  26. }
  27. },
  28. onBlock (account) {
  29. if (account.getIn(['relationship', 'blocking'])) {
  30. dispatch(unblockAccount(account.get('id')));
  31. } else {
  32. dispatch(blockAccount(account.get('id')));
  33. }
  34. },
  35. onMention (account, router) {
  36. dispatch(mentionCompose(account, router));
  37. },
  38. onReport (account) {
  39. dispatch(initReport(account));
  40. }
  41. });
  42. export default connect(makeMapStateToProps, mapDispatchToProps)(Header);