The code powering m.abunchtell.com https://m.abunchtell.com
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

68 satır
2.0 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  4. import { makeGetAccount } from '../selectors';
  5. import Account from '../components/account';
  6. import {
  7. followAccount,
  8. unfollowAccount,
  9. blockAccount,
  10. unblockAccount,
  11. muteAccount,
  12. unmuteAccount,
  13. } from '../actions/accounts';
  14. import { openModal } from '../actions/modal';
  15. import { unfollowModal } from '../initial_state';
  16. const messages = defineMessages({
  17. unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
  18. });
  19. const makeMapStateToProps = () => {
  20. const getAccount = makeGetAccount();
  21. const mapStateToProps = (state, props) => ({
  22. account: getAccount(state, props.id),
  23. });
  24. return mapStateToProps;
  25. };
  26. const mapDispatchToProps = (dispatch, { intl }) => ({
  27. onFollow (account) {
  28. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  29. if (unfollowModal) {
  30. dispatch(openModal('CONFIRM', {
  31. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  32. confirm: intl.formatMessage(messages.unfollowConfirm),
  33. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  34. }));
  35. } else {
  36. dispatch(unfollowAccount(account.get('id')));
  37. }
  38. } else {
  39. dispatch(followAccount(account.get('id')));
  40. }
  41. },
  42. onBlock (account) {
  43. if (account.getIn(['relationship', 'blocking'])) {
  44. dispatch(unblockAccount(account.get('id')));
  45. } else {
  46. dispatch(blockAccount(account.get('id')));
  47. }
  48. },
  49. onMute (account) {
  50. if (account.getIn(['relationship', 'muting'])) {
  51. dispatch(unmuteAccount(account.get('id')));
  52. } else {
  53. dispatch(muteAccount(account.get('id')));
  54. }
  55. },
  56. });
  57. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Account));