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.

56 lines
1.6 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import PropTypes from 'prop-types';
  5. import { expandAccountTimeline } from 'flavours/glitch/actions/timelines';
  6. import StatusList from '../../components/status_list';
  7. import { List as ImmutableList } from 'immutable';
  8. const mapStateToProps = (state, { accountId }) => {
  9. return {
  10. statusIds: state.getIn(['timelines', `account:${accountId}`, 'items'], ImmutableList()),
  11. isLoading: state.getIn(['timelines', `account:${accountId}`, 'isLoading']),
  12. hasMore: state.getIn(['timelines', `account:${accountId}`, 'hasMore']),
  13. };
  14. };
  15. class NewsBotStatuses extends React.PureComponent {
  16. static propTypes = {
  17. accountId: PropTypes.string.isRequired,
  18. dispatch: PropTypes.func.isRequired,
  19. statusIds: ImmutablePropTypes.list,
  20. isLoading: PropTypes.bool,
  21. hasMore: PropTypes.bool,
  22. multiColumn: PropTypes.bool,
  23. };
  24. componentDidMount () {
  25. this.props.dispatch(expandAccountTimeline(this.props.accountId));
  26. }
  27. handleLoadMore = maxId => {
  28. this.props.dispatch(expandAccountTimeline(this.props.accountId, { maxId }));
  29. };
  30. render () {
  31. const { statusIds, isLoading, hasMore, multiColumn } = this.props;
  32. return (
  33. <StatusList
  34. scrollKey='news_bot_timeline'
  35. statusIds={statusIds}
  36. isLoading={isLoading}
  37. hasMore={hasMore}
  38. onLoadMore={this.handleLoadMore}
  39. timelineId='news_bot'
  40. bindToDocument={!multiColumn}
  41. />
  42. );
  43. }
  44. }
  45. export default connect(mapStateToProps)(NewsBotStatuses);