The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

72 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 '../../ui/containers/status_list_container';
  5. import { expandCommunityTimeline } from '../../../actions/timelines';
  6. import Column from '../../../components/column';
  7. import ColumnHeader from '../../../components/column_header';
  8. import { defineMessages, injectIntl } from 'react-intl';
  9. import { connectCommunityStream } from '../../../actions/streaming';
  10. const messages = defineMessages({
  11. title: { id: 'standalone.public_title', defaultMessage: 'A look inside...' },
  12. });
  13. export default @connect()
  14. @injectIntl
  15. class CommunityTimeline 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(expandCommunityTimeline());
  29. this.disconnect = dispatch(connectCommunityStream());
  30. }
  31. componentWillUnmount () {
  32. if (this.disconnect) {
  33. this.disconnect();
  34. this.disconnect = null;
  35. }
  36. }
  37. handleLoadMore = maxId => {
  38. this.props.dispatch(expandCommunityTimeline({ 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='users'
  46. title={intl.formatMessage(messages.title)}
  47. onClick={this.handleHeaderClick}
  48. />
  49. <StatusListContainer
  50. timelineId='community'
  51. onLoadMore={this.handleLoadMore}
  52. scrollKey='standalone_public_timeline'
  53. trackScroll={false}
  54. />
  55. </Column>
  56. );
  57. }
  58. }