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.
 
 
 
 

60 lines
1.4 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. deleteFromTimelines
  9. } from '../../actions/timelines';
  10. import { injectIntl } from 'react-intl';
  11. const PublicTimeline = React.createClass({
  12. propTypes: {
  13. dispatch: React.PropTypes.func.isRequired
  14. },
  15. mixins: [PureRenderMixin],
  16. componentWillMount () {
  17. const { dispatch } = this.props;
  18. dispatch(refreshTimeline('public'));
  19. if (typeof App !== 'undefined') {
  20. this.subscription = App.cable.subscriptions.create('PublicChannel', {
  21. received (data) {
  22. switch(data.type) {
  23. case 'update':
  24. return dispatch(updateTimeline('public', JSON.parse(data.message)));
  25. case 'delete':
  26. return dispatch(deleteFromTimelines(data.id));
  27. }
  28. }
  29. });
  30. }
  31. },
  32. componentWillUnmount () {
  33. if (typeof this.subscription !== 'undefined') {
  34. this.subscription.unsubscribe();
  35. }
  36. },
  37. render () {
  38. const { intl } = this.props;
  39. return (
  40. <Column icon='globe' heading={intl.formatMessage({ id: 'column.public', defaultMessage: 'Public' })}>
  41. <StatusListContainer type='public' />
  42. </Column>
  43. );
  44. },
  45. });
  46. export default connect()(injectIntl(PublicTimeline));