logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

index.js (1751B)


  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 { expandPublicTimeline } 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 { connectPublicStream } from '../../../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}>
  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. }