闭社主体 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.

83 lines
1.8 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. });
  29. return mapStateToProps;
  30. };
  31. const mapDispatchToProps = (dispatch) => ({
  32. onReply (status, router) {
  33. dispatch(replyCompose(status, router));
  34. },
  35. onReblog (status) {
  36. if (status.get('reblogged')) {
  37. dispatch(unreblog(status));
  38. } else {
  39. dispatch(reblog(status));
  40. }
  41. },
  42. onFavourite (status) {
  43. if (status.get('favourited')) {
  44. dispatch(unfavourite(status));
  45. } else {
  46. dispatch(favourite(status));
  47. }
  48. },
  49. onDelete (status) {
  50. dispatch(deleteStatus(status.get('id')));
  51. },
  52. onMention (account, router) {
  53. dispatch(mentionCompose(account, router));
  54. },
  55. onOpenMedia (media, index) {
  56. dispatch(openModal('MEDIA', { media, index }));
  57. },
  58. onBlock (account) {
  59. dispatch(blockAccount(account.get('id')));
  60. },
  61. onReport (status) {
  62. dispatch(initReport(status.get('account'), status));
  63. },
  64. onMute (account) {
  65. dispatch(muteAccount(account.get('id')));
  66. },
  67. });
  68. export default connect(makeMapStateToProps, mapDispatchToProps)(Status);