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.9 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 'flavours/glitch/store/configureStore';
  6. import { hydrateStore } from 'flavours/glitch/actions/store';
  7. import { IntlProvider, addLocaleData } from 'react-intl';
  8. import { getLocale } from 'mastodon/locales';
  9. import PublicTimeline from 'flavours/glitch/features/standalone/public_timeline';
  10. import CommunityTimeline from 'flavours/glitch/features/standalone/community_timeline';
  11. import HashtagTimeline from 'flavours/glitch/features/standalone/hashtag_timeline';
  12. import ModalContainer from 'flavours/glitch/features/ui/containers/modal_container';
  13. import initialState from 'flavours/glitch/util/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. }