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.

62 lines
1.6 KiB

  1. import React, { Fragment } from 'react';
  2. import ReactDOM from 'react-dom';
  3. import { Provider } from 'react-redux';
  4. import PropTypes from 'prop-types';
  5. import configureStore from '../store/configureStore';
  6. import { hydrateStore } from '../actions/store';
  7. import { IntlProvider, addLocaleData } from 'react-intl';
  8. import { getLocale } from '../locales';
  9. import PublicTimeline from '../features/standalone/public_timeline';
  10. import HashtagTimeline from '../features/standalone/hashtag_timeline';
  11. import ModalContainer from '../features/ui/containers/modal_container';
  12. import initialState from '../initial_state';
  13. const { localeData, messages } = getLocale();
  14. addLocaleData(localeData);
  15. const store = configureStore();
  16. if (initialState) {
  17. store.dispatch(hydrateStore(initialState));
  18. }
  19. export default class TimelineContainer extends React.PureComponent {
  20. static propTypes = {
  21. locale: PropTypes.string.isRequired,
  22. hashtag: PropTypes.string,
  23. local: PropTypes.bool,
  24. };
  25. static defaultProps = {
  26. local: !initialState.settings.known_fediverse,
  27. };
  28. render () {
  29. const { locale, hashtag, local } = this.props;
  30. let timeline;
  31. if (hashtag) {
  32. timeline = <HashtagTimeline hashtag={hashtag} local={local} />;
  33. } else {
  34. timeline = <PublicTimeline local={local} />;
  35. }
  36. return (
  37. <IntlProvider locale={locale} messages={messages}>
  38. <Provider store={store}>
  39. <Fragment>
  40. {timeline}
  41. {ReactDOM.createPortal(
  42. <ModalContainer />,
  43. document.getElementById('modal-container'),
  44. )}
  45. </Fragment>
  46. </Provider>
  47. </IntlProvider>
  48. );
  49. }
  50. }