The code powering m.abunchtell.com https://m.abunchtell.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

51 rader
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);