The code powering m.abunchtell.com https://m.abunchtell.com
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

112 строки
3.9 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 {
  13. mentionCompose,
  14. directCompose,
  15. } from '../../../actions/compose';
  16. import { initMuteModal } from '../../../actions/mutes';
  17. import { initReport } from '../../../actions/reports';
  18. import { openModal } from '../../../actions/modal';
  19. import { blockDomain, unblockDomain } from '../../../actions/domain_blocks';
  20. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  21. import { unfollowModal } from '../../../initial_state';
  22. const messages = defineMessages({
  23. unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
  24. blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
  25. blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' },
  26. });
  27. const makeMapStateToProps = () => {
  28. const getAccount = makeGetAccount();
  29. const mapStateToProps = (state, { accountId }) => ({
  30. account: getAccount(state, accountId),
  31. });
  32. return mapStateToProps;
  33. };
  34. const mapDispatchToProps = (dispatch, { intl }) => ({
  35. onFollow (account) {
  36. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  37. if (unfollowModal) {
  38. dispatch(openModal('CONFIRM', {
  39. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  40. confirm: intl.formatMessage(messages.unfollowConfirm),
  41. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  42. }));
  43. } else {
  44. dispatch(unfollowAccount(account.get('id')));
  45. }
  46. } else {
  47. dispatch(followAccount(account.get('id')));
  48. }
  49. },
  50. onBlock (account) {
  51. if (account.getIn(['relationship', 'blocking'])) {
  52. dispatch(unblockAccount(account.get('id')));
  53. } else {
  54. dispatch(openModal('CONFIRM', {
  55. message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  56. confirm: intl.formatMessage(messages.blockConfirm),
  57. onConfirm: () => dispatch(blockAccount(account.get('id'))),
  58. }));
  59. }
  60. },
  61. onMention (account, router) {
  62. dispatch(mentionCompose(account, router));
  63. },
  64. onDirect (account, router) {
  65. dispatch(directCompose(account, router));
  66. },
  67. onReblogToggle (account) {
  68. if (account.getIn(['relationship', 'showing_reblogs'])) {
  69. dispatch(followAccount(account.get('id'), false));
  70. } else {
  71. dispatch(followAccount(account.get('id'), true));
  72. }
  73. },
  74. onReport (account) {
  75. dispatch(initReport(account));
  76. },
  77. onMute (account) {
  78. if (account.getIn(['relationship', 'muting'])) {
  79. dispatch(unmuteAccount(account.get('id')));
  80. } else {
  81. dispatch(initMuteModal(account));
  82. }
  83. },
  84. onBlockDomain (domain) {
  85. dispatch(openModal('CONFIRM', {
  86. 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. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.' values={{ domain: <strong>{domain}</strong> }} />,
  87. confirm: intl.formatMessage(messages.blockDomainConfirm),
  88. onConfirm: () => dispatch(blockDomain(domain)),
  89. }));
  90. },
  91. onUnblockDomain (domain) {
  92. dispatch(unblockDomain(domain));
  93. },
  94. });
  95. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));