The code powering m.abunchtell.com https://m.abunchtell.com
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

105 líneas
3.7 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. unmuteAccount,
  11. } from '../../../actions/accounts';
  12. import { mentionCompose } from '../../../actions/compose';
  13. import { initMuteModal } from '../../../actions/mutes';
  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. blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' },
  23. });
  24. const makeMapStateToProps = () => {
  25. const getAccount = makeGetAccount();
  26. const mapStateToProps = (state, { accountId }) => ({
  27. account: getAccount(state, accountId),
  28. });
  29. return mapStateToProps;
  30. };
  31. const mapDispatchToProps = (dispatch, { intl }) => ({
  32. onFollow (account) {
  33. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  34. if (unfollowModal) {
  35. dispatch(openModal('CONFIRM', {
  36. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  37. confirm: intl.formatMessage(messages.unfollowConfirm),
  38. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  39. }));
  40. } else {
  41. dispatch(unfollowAccount(account.get('id')));
  42. }
  43. } else {
  44. dispatch(followAccount(account.get('id')));
  45. }
  46. },
  47. onBlock (account) {
  48. if (account.getIn(['relationship', 'blocking'])) {
  49. dispatch(unblockAccount(account.get('id')));
  50. } else {
  51. dispatch(openModal('CONFIRM', {
  52. message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  53. confirm: intl.formatMessage(messages.blockConfirm),
  54. onConfirm: () => dispatch(blockAccount(account.get('id'))),
  55. }));
  56. }
  57. },
  58. onMention (account, router) {
  59. dispatch(mentionCompose(account, router));
  60. },
  61. onReblogToggle (account) {
  62. if (account.getIn(['relationship', 'showing_reblogs'])) {
  63. dispatch(followAccount(account.get('id'), false));
  64. } else {
  65. dispatch(followAccount(account.get('id'), true));
  66. }
  67. },
  68. onReport (account) {
  69. dispatch(initReport(account));
  70. },
  71. onMute (account) {
  72. if (account.getIn(['relationship', 'muting'])) {
  73. dispatch(unmuteAccount(account.get('id')));
  74. } else {
  75. dispatch(initMuteModal(account));
  76. }
  77. },
  78. onBlockDomain (domain, accountId) {
  79. dispatch(openModal('CONFIRM', {
  80. 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> }} />,
  81. confirm: intl.formatMessage(messages.blockDomainConfirm),
  82. onConfirm: () => dispatch(blockDomain(domain, accountId)),
  83. }));
  84. },
  85. onUnblockDomain (domain, accountId) {
  86. dispatch(unblockDomain(domain, accountId));
  87. },
  88. });
  89. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));