闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.2 KiB

  1. import { connect } from 'react-redux';
  2. import Status from '../components/status';
  3. import { makeGetStatus } from '../selectors';
  4. import {
  5. replyCompose,
  6. mentionCompose
  7. } from '../actions/compose';
  8. import {
  9. reblog,
  10. favourite,
  11. unreblog,
  12. unfavourite
  13. } from '../actions/interactions';
  14. import {
  15. blockAccount,
  16. muteAccount
  17. } from '../actions/accounts';
  18. import { deleteStatus } from '../actions/statuses';
  19. import { initReport } from '../actions/reports';
  20. import { openModal } from '../actions/modal';
  21. import { createSelector } from 'reselect'
  22. import { isMobile } from '../is_mobile'
  23. const makeMapStateToProps = () => {
  24. const getStatus = makeGetStatus();
  25. const mapStateToProps = (state, props) => ({
  26. status: getStatus(state, props.id),
  27. me: state.getIn(['meta', 'me']),
  28. boostModal: state.getIn(['meta', 'boost_modal']),
  29. autoPlayGif: state.getIn(['meta', 'auto_play_gif'])
  30. });
  31. return mapStateToProps;
  32. };
  33. const mapDispatchToProps = (dispatch) => ({
  34. onReply (status, router) {
  35. dispatch(replyCompose(status, router));
  36. },
  37. onModalReblog (status) {
  38. dispatch(reblog(status));
  39. },
  40. onReblog (status, e) {
  41. if (status.get('reblogged')) {
  42. dispatch(unreblog(status));
  43. } else {
  44. if (e.shiftKey || !this.boostModal) {
  45. this.onModalReblog(status);
  46. } else {
  47. dispatch(openModal('BOOST', { status, onReblog: this.onModalReblog }));
  48. }
  49. }
  50. },
  51. onFavourite (status) {
  52. if (status.get('favourited')) {
  53. dispatch(unfavourite(status));
  54. } else {
  55. dispatch(favourite(status));
  56. }
  57. },
  58. onDelete (status) {
  59. dispatch(deleteStatus(status.get('id')));
  60. },
  61. onMention (account, router) {
  62. dispatch(mentionCompose(account, router));
  63. },
  64. onOpenMedia (media, index) {
  65. dispatch(openModal('MEDIA', { media, index }));
  66. },
  67. onOpenVideo (media, time) {
  68. dispatch(openModal('VIDEO', { media, time }));
  69. },
  70. onBlock (account) {
  71. dispatch(blockAccount(account.get('id')));
  72. },
  73. onReport (status) {
  74. dispatch(initReport(status.get('account'), status));
  75. },
  76. onMute (account) {
  77. dispatch(muteAccount(account.get('id')));
  78. },
  79. });
  80. export default connect(makeMapStateToProps, mapDispatchToProps)(Status);