The code powering m.abunchtell.com https://m.abunchtell.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

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