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.

40 lines
1.1 KiB

  1. import { connect } from 'react-redux';
  2. import StatusList from '../components/status_list';
  3. import { replyCompose } from '../actions/compose';
  4. import { reblog, favourite } from '../actions/interactions';
  5. function selectStatus(state, id) {
  6. let status = state.getIn(['timelines', 'statuses', id]);
  7. status = status.set('account', state.getIn(['timelines', 'accounts', status.get('account')]));
  8. if (status.get('reblog') !== null) {
  9. status = status.set('reblog', selectStatus(state, status.get('reblog')));
  10. }
  11. return status;
  12. };
  13. const mapStateToProps = function (state, props) {
  14. return {
  15. statuses: state.getIn(['timelines', props.type]).map(id => selectStatus(state, id))
  16. };
  17. };
  18. const mapDispatchToProps = function (dispatch) {
  19. return {
  20. onReply: function (status) {
  21. dispatch(replyCompose(status));
  22. },
  23. onFavourite: function (status) {
  24. dispatch(favourite(status));
  25. },
  26. onReblog: function (status) {
  27. dispatch(reblog(status));
  28. }
  29. };
  30. };
  31. export default connect(mapStateToProps, mapDispatchToProps)(StatusList);