The code powering m.abunchtell.com https://m.abunchtell.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

102 linhas
3.8 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { makeGetAccount } from '../../../selectors';
  4. import Header from '../components/header';
  5. import {
  6. followAccount,
  7. unfollowAccount,
  8. blockAccount,
  9. unblockAccount,
  10. muteAccount,
  11. unmuteAccount,
  12. } from '../../../actions/accounts';
  13. import { mentionCompose } from '../../../actions/compose';
  14. import { initReport } from '../../../actions/reports';
  15. import { openModal } from '../../../actions/modal';
  16. import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
  17. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  18. import { unfollowModal } from '../../../initial_state';
  19. const messages = defineMessages({
  20. unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
  21. blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
  22. muteConfirm: { id: 'confirmations.mute.confirm', defaultMessage: 'Mute' },
  23. blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' },
  24. });
  25. const makeMapStateToProps = () => {
  26. const getAccount = makeGetAccount();
  27. const mapStateToProps = (state, { accountId }) => ({
  28. account: getAccount(state, accountId),
  29. });
  30. return mapStateToProps;
  31. };
  32. const mapDispatchToProps = (dispatch, { intl }) => ({
  33. onFollow (account) {
  34. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  35. if (unfollowModal) {
  36. dispatch(openModal('CONFIRM', {
  37. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  38. confirm: intl.formatMessage(messages.unfollowConfirm),
  39. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  40. }));
  41. } else {
  42. dispatch(unfollowAccount(account.get('id')));
  43. }
  44. } else {
  45. dispatch(followAccount(account.get('id')));
  46. }
  47. },
  48. onBlock (account) {
  49. if (account.getIn(['relationship', 'blocking'])) {
  50. dispatch(unblockAccount(account.get('id')));
  51. } else {
  52. dispatch(openModal('CONFIRM', {
  53. message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  54. confirm: intl.formatMessage(messages.blockConfirm),
  55. onConfirm: () => dispatch(blockAccount(account.get('id'))),
  56. }));
  57. }
  58. },
  59. onMention (account, router) {
  60. dispatch(mentionCompose(account, router));
  61. },
  62. onReport (account) {
  63. dispatch(initReport(account));
  64. },
  65. onMute (account) {
  66. if (account.getIn(['relationship', 'muting'])) {
  67. dispatch(unmuteAccount(account.get('id')));
  68. } else {
  69. dispatch(openModal('CONFIRM', {
  70. message: <FormattedMessage id='confirmations.mute.message' defaultMessage='Are you sure you want to mute {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  71. confirm: intl.formatMessage(messages.muteConfirm),
  72. onConfirm: () => dispatch(muteAccount(account.get('id'))),
  73. }));
  74. }
  75. },
  76. onBlockDomain (domain, accountId) {
  77. dispatch(openModal('CONFIRM', {
  78. message: <FormattedMessage id='confirmations.domain_block.message' defaultMessage='Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable.' values={{ domain: <strong>{domain}</strong> }} />,
  79. confirm: intl.formatMessage(messages.blockDomainConfirm),
  80. onConfirm: () => dispatch(blockDomain(domain, accountId)),
  81. }));
  82. },
  83. onUnblockDomain (domain, accountId) {
  84. dispatch(unblockDomain(domain, accountId));
  85. },
  86. });
  87. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));