The code powering m.abunchtell.com https://m.abunchtell.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

126 righe
4.0 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. unblockAccount,
  9. unmuteAccount,
  10. pinAccount,
  11. unpinAccount,
  12. } from '../../../actions/accounts';
  13. import {
  14. mentionCompose,
  15. directCompose,
  16. } from '../../../actions/compose';
  17. import { initMuteModal } from '../../../actions/mutes';
  18. import { initBlockModal } from '../../../actions/blocks';
  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. import { List as ImmutableList } from 'immutable';
  25. const messages = defineMessages({
  26. unfollowConfirm: { id: 'confirmations.unfollow.confirm', defaultMessage: 'Unfollow' },
  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. domain: state.getIn(['meta', 'domain']),
  34. identity_proofs: state.getIn(['identity_proofs', accountId], ImmutableList()),
  35. });
  36. return mapStateToProps;
  37. };
  38. const mapDispatchToProps = (dispatch, { intl }) => ({
  39. onFollow (account) {
  40. if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
  41. if (unfollowModal) {
  42. dispatch(openModal('CONFIRM', {
  43. message: <FormattedMessage id='confirmations.unfollow.message' defaultMessage='Are you sure you want to unfollow {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  44. confirm: intl.formatMessage(messages.unfollowConfirm),
  45. onConfirm: () => dispatch(unfollowAccount(account.get('id'))),
  46. }));
  47. } else {
  48. dispatch(unfollowAccount(account.get('id')));
  49. }
  50. } else {
  51. dispatch(followAccount(account.get('id')));
  52. }
  53. },
  54. onBlock (account) {
  55. if (account.getIn(['relationship', 'blocking'])) {
  56. dispatch(unblockAccount(account.get('id')));
  57. } else {
  58. dispatch(initBlockModal(account));
  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. onEndorseToggle (account) {
  75. if (account.getIn(['relationship', 'endorsed'])) {
  76. dispatch(unpinAccount(account.get('id')));
  77. } else {
  78. dispatch(pinAccount(account.get('id')));
  79. }
  80. },
  81. onReport (account) {
  82. dispatch(initReport(account));
  83. },
  84. onMute (account) {
  85. if (account.getIn(['relationship', 'muting'])) {
  86. dispatch(unmuteAccount(account.get('id')));
  87. } else {
  88. dispatch(initMuteModal(account));
  89. }
  90. },
  91. onBlockDomain (domain) {
  92. dispatch(openModal('CONFIRM', {
  93. 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> }} />,
  94. confirm: intl.formatMessage(messages.blockDomainConfirm),
  95. onConfirm: () => dispatch(blockDomain(domain)),
  96. }));
  97. },
  98. onUnblockDomain (domain) {
  99. dispatch(unblockDomain(domain));
  100. },
  101. onAddToList(account){
  102. dispatch(openModal('LIST_ADDER', {
  103. accountId: account.get('id'),
  104. }));
  105. },
  106. });
  107. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Header));