Send initial state in a <script type="application/json"> tag (#1806)
This commit is contained in:
parent
9240ca6cef
commit
ef879a8839
9 changed files with 25 additions and 17 deletions
|
@ -61,8 +61,8 @@ import { hydrateStore } from '../actions/store';
|
|||
import createStream from '../stream';
|
||||
|
||||
const store = configureStore();
|
||||
|
||||
store.dispatch(hydrateStore(window.INITIAL_STATE));
|
||||
const initialState = JSON.parse(document.getElementById("initial-state").textContent);
|
||||
store.dispatch(hydrateStore(initialState));
|
||||
|
||||
const browserHistory = useRouterHistory(createBrowserHistory)({
|
||||
basename: '/web'
|
||||
|
@ -95,9 +95,10 @@ const Mastodon = React.createClass({
|
|||
|
||||
componentDidMount() {
|
||||
const { locale } = this.props;
|
||||
const streamingAPIBaseURL = store.getState().getIn(['meta', 'streaming_api_base_url']);
|
||||
const accessToken = store.getState().getIn(['meta', 'access_token']);
|
||||
|
||||
this.subscription = createStream(accessToken, 'user', {
|
||||
this.subscription = createStream(streamingAPIBaseURL, accessToken, 'user', {
|
||||
|
||||
connected () {
|
||||
store.dispatch(connectTimeline('home'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue