2016-11-09 18:47:47 -05:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-10-12 07:17:17 -04:00
|
|
|
import StatusListContainer from '../ui/containers/status_list_container';
|
2016-11-09 18:47:47 -05:00
|
|
|
import Column from '../ui/components/column';
|
2016-10-07 10:00:11 -04:00
|
|
|
import {
|
|
|
|
refreshTimeline,
|
2016-11-09 18:47:47 -05:00
|
|
|
updateTimeline,
|
|
|
|
deleteFromTimelines
|
|
|
|
} from '../../actions/timelines';
|
2016-11-18 09:36:16 -05:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2017-01-30 09:22:04 -05:00
|
|
|
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
|
2016-11-18 09:36:16 -05:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
title: { id: 'column.public', defaultMessage: 'Public' }
|
|
|
|
});
|
2016-10-07 10:00:11 -04:00
|
|
|
|
|
|
|
const PublicTimeline = React.createClass({
|
|
|
|
|
2016-10-16 13:23:17 -04:00
|
|
|
propTypes: {
|
2017-01-02 19:15:42 -05:00
|
|
|
dispatch: React.PropTypes.func.isRequired,
|
|
|
|
intl: React.PropTypes.object.isRequired
|
2016-10-16 13:23:17 -04:00
|
|
|
},
|
|
|
|
|
2016-10-07 10:00:11 -04:00
|
|
|
mixins: [PureRenderMixin],
|
|
|
|
|
|
|
|
componentWillMount () {
|
|
|
|
const { dispatch } = this.props;
|
|
|
|
|
|
|
|
dispatch(refreshTimeline('public'));
|
|
|
|
|
|
|
|
if (typeof App !== 'undefined') {
|
|
|
|
this.subscription = App.cable.subscriptions.create('PublicChannel', {
|
|
|
|
|
|
|
|
received (data) {
|
2017-02-01 18:03:31 -05:00
|
|
|
switch(data.event) {
|
2017-01-30 09:22:04 -05:00
|
|
|
case 'update':
|
2017-02-01 18:03:31 -05:00
|
|
|
dispatch(updateTimeline('public', JSON.parse(data.payload)));
|
|
|
|
break;
|
2017-01-30 09:22:04 -05:00
|
|
|
case 'delete':
|
2017-02-01 18:03:31 -05:00
|
|
|
dispatch(deleteFromTimelines(data.payload));
|
|
|
|
break;
|
2016-11-09 18:47:47 -05:00
|
|
|
}
|
2016-10-07 10:00:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
if (typeof this.subscription !== 'undefined') {
|
|
|
|
this.subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
2016-11-16 11:20:52 -05:00
|
|
|
const { intl } = this.props;
|
|
|
|
|
2016-10-07 10:00:11 -04:00
|
|
|
return (
|
2016-11-18 09:36:16 -05:00
|
|
|
<Column icon='globe' heading={intl.formatMessage(messages.title)}>
|
2017-01-30 09:22:04 -05:00
|
|
|
<ColumnBackButtonSlim />
|
2016-10-12 07:17:17 -04:00
|
|
|
<StatusListContainer type='public' />
|
2016-10-07 10:00:11 -04:00
|
|
|
</Column>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-11-16 11:20:52 -05:00
|
|
|
export default connect()(injectIntl(PublicTimeline));
|