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.

71 lines
1.8 KiB

  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import PropTypes from 'prop-types';
  4. import StatusListContainer from 'flavours/glitch/features/ui/containers/status_list_container';
  5. import { expandPublicTimeline } from 'flavours/glitch/actions/timelines';
  6. import Column from 'flavours/glitch/components/column';
  7. import ColumnHeader from 'flavours/glitch/components/column_header';
  8. import { defineMessages, injectIntl } from 'react-intl';
  9. import { connectPublicStream } from 'flavours/glitch/actions/streaming';
  10. const messages = defineMessages({
  11. title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
  12. });
  13. @connect()
  14. @injectIntl
  15. export default class PublicTimeline extends React.PureComponent {
  16. static propTypes = {
  17. dispatch: PropTypes.func.isRequired,
  18. intl: PropTypes.object.isRequired,
  19. };
  20. handleHeaderClick = () => {
  21. this.column.scrollTop();
  22. }
  23. setRef = c => {
  24. this.column = c;
  25. }
  26. componentDidMount () {
  27. const { dispatch } = this.props;
  28. dispatch(expandPublicTimeline());
  29. this.disconnect = dispatch(connectPublicStream());
  30. }
  31. componentWillUnmount () {
  32. if (this.disconnect) {
  33. this.disconnect();
  34. this.disconnect = null;
  35. }
  36. }
  37. handleLoadMore = maxId => {
  38. this.props.dispatch(expandPublicTimeline({ maxId }));
  39. }
  40. render () {
  41. const { intl } = this.props;
  42. return (
  43. <Column ref={this.setRef} label={intl.formatMessage(messages.title)}>
  44. <ColumnHeader
  45. icon='globe'
  46. title={intl.formatMessage(messages.title)}
  47. onClick={this.handleHeaderClick}
  48. />
  49. <StatusListContainer
  50. timelineId='public'
  51. onLoadMore={this.handleLoadMore}
  52. scrollKey='standalone_public_timeline'
  53. trackScroll={false}
  54. />
  55. </Column>
  56. );
  57. }
  58. }