Add document title handling
This commit is contained in:
parent
511b9e406c
commit
2afbf2359c
8 changed files with 156 additions and 65 deletions
40
client/src/js/modules/initialState.js
Normal file
40
client/src/js/modules/initialState.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { setEnvironment } from '../actions/environment';
|
||||
import { addMessages } from '../actions/message';
|
||||
import { initWidthUpdates } from '../util/messageHeight';
|
||||
import { replace } from '../util/router';
|
||||
|
||||
export default function initialState({ store }) {
|
||||
const env = JSON.parse(document.getElementById('env').innerHTML);
|
||||
|
||||
store.dispatch(setEnvironment('connect_defaults', env.defaults));
|
||||
|
||||
if (env.servers) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_SERVERS',
|
||||
data: env.servers
|
||||
});
|
||||
} else {
|
||||
store.dispatch(replace('/connect'));
|
||||
}
|
||||
|
||||
if (env.channels) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_CHANNELS',
|
||||
data: env.channels
|
||||
});
|
||||
}
|
||||
|
||||
if (env.users) {
|
||||
store.dispatch({
|
||||
type: 'SOCKET_USERS',
|
||||
...env.users
|
||||
});
|
||||
}
|
||||
|
||||
initWidthUpdates(store, () => {
|
||||
if (env.messages) {
|
||||
const { messages, server, to, next } = env.messages;
|
||||
store.dispatch(addMessages(messages, server, to, false, next));
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue