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.

64 lines
1.8 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 CommunityTimeline from '../features/standalone/community_timeline';
  11. import HashtagTimeline from '../features/standalone/hashtag_timeline';
  12. import ModalContainer from '../features/ui/containers/modal_container';
  13. import initialState from '../initial_state';
  14. const { localeData, messages } = getLocale();
  15. addLocaleData(localeData);
  16. const store = configureStore();
  17. if (initialState) {
  18. store.dispatch(hydrateStore(initialState));
  19. }
  20. export default class TimelineContainer extends React.PureComponent {
  21. static propTypes = {
  22. locale: PropTypes.string.isRequired,
  23. hashtag: PropTypes.string,
  24. showPublicTimeline: PropTypes.bool.isRequired,
  25. };
  26. static defaultProps = {
  27. showPublicTimeline: initialState.settings.known_fediverse,
  28. };
  29. render () {
  30. const { locale, hashtag, showPublicTimeline } = this.props;
  31. let timeline;
  32. if (hashtag) {
  33. timeline = <HashtagTimeline hashtag={hashtag} />;
  34. } else if (showPublicTimeline) {
  35. timeline = <PublicTimeline />;
  36. } else {
  37. timeline = <CommunityTimeline />;
  38. }
  39. return (
  40. <IntlProvider locale={locale} messages={messages}>
  41. <Provider store={store}>
  42. <Fragment>
  43. {timeline}
  44. {ReactDOM.createPortal(
  45. <ModalContainer />,
  46. document.getElementById('modal-container'),
  47. )}
  48. </Fragment>
  49. </Provider>
  50. </IntlProvider>
  51. );
  52. }
  53. }