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.

65 lines
1.6 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import StatusListContainer from '../../ui/containers/status_list_container';
  5. import { expandHashtagTimeline } from '../../../actions/timelines';
  6. import Column from '../../../components/column';
  7. import ColumnHeader from '../../../components/column_header';
  8. import { connectHashtagStream } from '../../../actions/streaming';
  9. export default @connect()
  10. class HashtagTimeline extends React.PureComponent {
  11. static propTypes = {
  12. dispatch: PropTypes.func.isRequired,
  13. hashtag: PropTypes.string.isRequired,
  14. };
  15. handleHeaderClick = () => {
  16. this.column.scrollTop();
  17. }
  18. setRef = c => {
  19. this.column = c;
  20. }
  21. componentDidMount () {
  22. const { dispatch, hashtag } = this.props;
  23. dispatch(expandHashtagTimeline(hashtag));
  24. this.disconnect = dispatch(connectHashtagStream(hashtag));
  25. }
  26. componentWillUnmount () {
  27. if (this.disconnect) {
  28. this.disconnect();
  29. this.disconnect = null;
  30. }
  31. }
  32. handleLoadMore = maxId => {
  33. this.props.dispatch(expandHashtagTimeline(this.props.hashtag, { maxId }));
  34. }
  35. render () {
  36. const { hashtag } = this.props;
  37. return (
  38. <Column ref={this.setRef}>
  39. <ColumnHeader
  40. icon='hashtag'
  41. title={hashtag}
  42. onClick={this.handleHeaderClick}
  43. />
  44. <StatusListContainer
  45. trackScroll={false}
  46. scrollKey='standalone_hashtag_timeline'
  47. timelineId={`hashtag:${hashtag}`}
  48. onLoadMore={this.handleLoadMore}
  49. />
  50. </Column>
  51. );
  52. }
  53. }