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.

40 lines
1.0 KiB

  1. import { Provider } from 'react-redux';
  2. import configureStore from '../store/configureStore';
  3. import Frontend from '../components/frontend';
  4. import { setTimeline, addStatus } from '../actions/statuses';
  5. const store = configureStore();
  6. const Root = React.createClass({
  7. componentWillMount() {
  8. for (var timelineType in this.props.timelines) {
  9. if (this.props.timelines.hasOwnProperty(timelineType)) {
  10. store.dispatch(setTimeline(timelineType, JSON.parse(this.props.timelines[timelineType])));
  11. }
  12. }
  13. if (typeof App !== 'undefined') {
  14. App.timeline = App.cable.subscriptions.create("TimelineChannel", {
  15. connected: function() {},
  16. disconnected: function() {},
  17. received: function(data) {
  18. return store.dispatch(addStatus(data.timeline, JSON.parse(data.message)));
  19. }
  20. });
  21. }
  22. },
  23. render() {
  24. return (
  25. <Provider store={store}>
  26. <Frontend />
  27. </Provider>
  28. );
  29. }
  30. });
  31. export default Root;