2018-05-08 07:33:09 -04:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2017-07-11 09:27:59 -04:00
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import configureStore from '../store/configureStore';
|
|
|
|
import { hydrateStore } from '../actions/store';
|
|
|
|
import { IntlProvider, addLocaleData } from 'react-intl';
|
|
|
|
import { getLocale } from '../locales';
|
|
|
|
import PublicTimeline from '../features/standalone/public_timeline';
|
2018-02-04 00:00:10 -05:00
|
|
|
import CommunityTimeline from '../features/standalone/community_timeline';
|
2017-10-07 14:00:35 -04:00
|
|
|
import HashtagTimeline from '../features/standalone/hashtag_timeline';
|
2018-05-08 07:33:09 -04:00
|
|
|
import ModalContainer from '../features/ui/containers/modal_container';
|
2017-10-27 11:04:44 -04:00
|
|
|
import initialState from '../initial_state';
|
2017-07-11 09:27:59 -04:00
|
|
|
|
|
|
|
const { localeData, messages } = getLocale();
|
|
|
|
addLocaleData(localeData);
|
|
|
|
|
|
|
|
const store = configureStore();
|
|
|
|
|
2017-10-27 11:04:44 -04:00
|
|
|
if (initialState) {
|
2017-07-11 09:27:59 -04:00
|
|
|
store.dispatch(hydrateStore(initialState));
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class TimelineContainer extends React.PureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
locale: PropTypes.string.isRequired,
|
2017-10-07 14:00:35 -04:00
|
|
|
hashtag: PropTypes.string,
|
2018-02-04 00:00:10 -05:00
|
|
|
showPublicTimeline: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
showPublicTimeline: initialState.settings.known_fediverse,
|
2017-07-11 09:27:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2018-02-04 00:00:10 -05:00
|
|
|
const { locale, hashtag, showPublicTimeline } = this.props;
|
2017-10-07 14:00:35 -04:00
|
|
|
|
|
|
|
let timeline;
|
|
|
|
|
|
|
|
if (hashtag) {
|
|
|
|
timeline = <HashtagTimeline hashtag={hashtag} />;
|
2018-02-04 00:00:10 -05:00
|
|
|
} else if (showPublicTimeline) {
|
2017-10-07 14:00:35 -04:00
|
|
|
timeline = <PublicTimeline />;
|
2018-02-04 00:00:10 -05:00
|
|
|
} else {
|
|
|
|
timeline = <CommunityTimeline />;
|
2017-10-07 14:00:35 -04:00
|
|
|
}
|
2017-07-11 09:27:59 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<IntlProvider locale={locale} messages={messages}>
|
|
|
|
<Provider store={store}>
|
2018-05-08 07:33:09 -04:00
|
|
|
<Fragment>
|
|
|
|
{timeline}
|
|
|
|
{ReactDOM.createPortal(
|
|
|
|
<ModalContainer />,
|
|
|
|
document.getElementById('modal-container'),
|
|
|
|
)}
|
|
|
|
</Fragment>
|
2017-07-11 09:27:59 -04:00
|
|
|
</Provider>
|
|
|
|
</IntlProvider>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|