logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

status_container.js (3697B)


  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import Status from '../components/status';
  4. import { makeGetStatus } from '../selectors';
  5. import {
  6. replyCompose,
  7. mentionCompose,
  8. directCompose,
  9. } from '../actions/compose';
  10. import {
  11. reblog,
  12. favourite,
  13. unreblog,
  14. unfavourite,
  15. } from '../actions/interactions';
  16. import { blockAccount } from '../actions/accounts';
  17. import {
  18. muteStatus,
  19. unmuteStatus,
  20. deleteStatus,
  21. hideStatus,
  22. revealStatus,
  23. } from '../actions/statuses';
  24. import { initMuteModal } from '../actions/mutes';
  25. import { initReport } from '../actions/reports';
  26. import { openModal } from '../actions/modal';
  27. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  28. import { boostModal, deleteModal } from '../initial_state';
  29. import { showAlertForError } from '../actions/alerts';
  30. const messages = defineMessages({
  31. deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
  32. deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
  33. blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
  34. });
  35. const makeMapStateToProps = () => {
  36. const getStatus = makeGetStatus();
  37. const mapStateToProps = (state, props) => ({
  38. status: getStatus(state, props.id),
  39. });
  40. return mapStateToProps;
  41. };
  42. const mapDispatchToProps = (dispatch, { intl }) => ({
  43. onReply (status, router) {
  44. dispatch(replyCompose(status, router));
  45. },
  46. onModalReblog (status) {
  47. dispatch(reblog(status));
  48. },
  49. onReblog (status, e) {
  50. if (status.get('reblogged')) {
  51. dispatch(unreblog(status));
  52. } else {
  53. if (e.shiftKey || !boostModal) {
  54. this.onModalReblog(status);
  55. } else {
  56. dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
  57. }
  58. }
  59. },
  60. onFavourite (status) {
  61. if (status.get('favourited')) {
  62. dispatch(unfavourite(status));
  63. } else {
  64. dispatch(favourite(status));
  65. }
  66. },
  67. onDelete (status) {
  68. if (!deleteModal) {
  69. dispatch(deleteStatus(status.get('id')));
  70. } else {
  71. dispatch(openModal('CONFIRM', {
  72. message: intl.formatMessage(messages.deleteMessage),
  73. confirm: intl.formatMessage(messages.deleteConfirm),
  74. onConfirm: () => dispatch(deleteStatus(status.get('id'))),
  75. }));
  76. }
  77. },
  78. onDirect (account, router) {
  79. dispatch(directCompose(account, router));
  80. },
  81. onMention (account, router) {
  82. dispatch(mentionCompose(account, router));
  83. },
  84. onOpenMedia (media, index) {
  85. dispatch(openModal('MEDIA', { media, index }));
  86. },
  87. onOpenVideo (media, time) {
  88. dispatch(openModal('VIDEO', { media, time }));
  89. },
  90. onBlock (account) {
  91. dispatch(openModal('CONFIRM', {
  92. message: <FormattedMessage id='confirmations.block.message' defaultMessage='Are you sure you want to block {name}?' values={{ name: <strong>@{account.get('acct')}</strong> }} />,
  93. confirm: intl.formatMessage(messages.blockConfirm),
  94. onConfirm: () => dispatch(blockAccount(account.get('id'))),
  95. }));
  96. },
  97. onReport (status) {
  98. dispatch(initReport(status.get('account'), status));
  99. },
  100. onMute (account) {
  101. dispatch(initMuteModal(account));
  102. },
  103. onMuteConversation (status) {
  104. if (status.get('muted')) {
  105. dispatch(unmuteStatus(status.get('id')));
  106. } else {
  107. dispatch(muteStatus(status.get('id')));
  108. }
  109. },
  110. onToggleHidden (status) {
  111. if (status.get('hidden')) {
  112. dispatch(revealStatus(status.get('id')));
  113. } else {
  114. dispatch(hideStatus(status.get('id')));
  115. }
  116. },
  117. });
  118. export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));