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

76 lines
1.7 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 {
  6. refreshPublicTimeline,
  7. expandPublicTimeline,
  8. } from '../../../actions/timelines';
  9. import Column from '../../../components/column';
  10. import ColumnHeader from '../../../components/column_header';
  11. import { defineMessages, injectIntl } from 'react-intl';
  12. const messages = defineMessages({
  13. title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
  14. });
  15. @connect()
  16. @injectIntl
  17. export default class PublicTimeline extends React.PureComponent {
  18. static propTypes = {
  19. dispatch: PropTypes.func.isRequired,
  20. intl: PropTypes.object.isRequired,
  21. };
  22. handleHeaderClick = () => {
  23. this.column.scrollTop();
  24. }
  25. setRef = c => {
  26. this.column = c;
  27. }
  28. componentDidMount () {
  29. const { dispatch } = this.props;
  30. dispatch(refreshPublicTimeline());
  31. this.polling = setInterval(() => {
  32. dispatch(refreshPublicTimeline());
  33. }, 3000);
  34. }
  35. componentWillUnmount () {
  36. if (typeof this.polling !== 'undefined') {
  37. clearInterval(this.polling);
  38. this.polling = null;
  39. }
  40. }
  41. handleLoadMore = () => {
  42. this.props.dispatch(expandPublicTimeline());
  43. }
  44. render () {
  45. const { intl } = this.props;
  46. return (
  47. <Column ref={this.setRef}>
  48. <ColumnHeader
  49. icon='globe'
  50. title={intl.formatMessage(messages.title)}
  51. onClick={this.handleHeaderClick}
  52. />
  53. <StatusListContainer
  54. timelineId='public'
  55. loadMore={this.handleLoadMore}
  56. scrollKey='standalone_public_timeline'
  57. trackScroll={false}
  58. />
  59. </Column>
  60. );
  61. }
  62. }