Embed servers, channels and users in index.html
This commit is contained in:
parent
04d61dd9a6
commit
22d8b8b363
7 changed files with 123 additions and 45 deletions
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { routeActions } from 'redux-simple-router';
|
||||
import configureStore from './store';
|
||||
import createRoutes from './routes';
|
||||
import Socket from './util/Socket';
|
||||
|
@ -11,6 +12,30 @@ const host = __DEV__ ? `${window.location.hostname}:1337` : window.location.host
|
|||
const socket = new Socket(host);
|
||||
|
||||
const store = configureStore(socket, browserHistory);
|
||||
|
||||
if (window.__ENV__.servers) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_SERVERS',
|
||||
data: window.__ENV__.servers
|
||||
});
|
||||
} else {
|
||||
store.dispatch(routeActions.replace('/connect'));
|
||||
}
|
||||
|
||||
if (window.__ENV__.channels) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_CHANNELS',
|
||||
data: window.__ENV__.channels
|
||||
});
|
||||
}
|
||||
|
||||
if (window.__ENV__.users) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_USERS',
|
||||
...window.__ENV__.users
|
||||
});
|
||||
}
|
||||
|
||||
handleSocket(socket, store);
|
||||
|
||||
const routes = createRoutes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue