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

50 lines
1.1 KiB

  1. import { connect } from 'react-redux';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. import StatusListContainer from '../ui/containers/status_list_container';
  4. import Column from '../ui/components/column';
  5. import {
  6. refreshTimeline,
  7. updateTimeline
  8. } from '../../actions/timelines';
  9. const PublicTimeline = React.createClass({
  10. propTypes: {
  11. dispatch: React.PropTypes.func.isRequired
  12. },
  13. mixins: [PureRenderMixin],
  14. componentWillMount () {
  15. const { dispatch } = this.props;
  16. dispatch(refreshTimeline('public'));
  17. if (typeof App !== 'undefined') {
  18. this.subscription = App.cable.subscriptions.create('PublicChannel', {
  19. received (data) {
  20. dispatch(updateTimeline('public', JSON.parse(data.message)));
  21. }
  22. });
  23. }
  24. },
  25. componentWillUnmount () {
  26. if (typeof this.subscription !== 'undefined') {
  27. this.subscription.unsubscribe();
  28. }
  29. },
  30. render () {
  31. return (
  32. <Column icon='globe' heading='Public'>
  33. <StatusListContainer type='public' />
  34. </Column>
  35. );
  36. },
  37. });
  38. export default connect()(PublicTimeline);