Clean up initialState module
This commit is contained in:
parent
c1ca29511e
commit
0e46fbcc82
File diff suppressed because one or more lines are too long
@ -1,13 +1,10 @@
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
|
||||
import { socket as socketActions } from 'state/actions';
|
||||
import { getWrapWidth, setConnectDefaults, appSet } from 'state/app';
|
||||
import { getWrapWidth, appSet } from 'state/app';
|
||||
import { addMessages } from 'state/messages';
|
||||
import { setSettings } from 'state/settings';
|
||||
import { when } from 'utils/observe';
|
||||
|
||||
function loadState({ store }, env) {
|
||||
store.dispatch(setConnectDefaults(env.defaults));
|
||||
store.dispatch(setSettings(env.settings, true));
|
||||
|
||||
if (env.servers) {
|
||||
@ -33,22 +30,24 @@ function loadState({ store }, env) {
|
||||
|
||||
store.dispatch(
|
||||
appSet({
|
||||
connectDefaults: env.defaults,
|
||||
initialized: true,
|
||||
hexIP: env.hexIP,
|
||||
version: env.version
|
||||
})
|
||||
);
|
||||
|
||||
// Wait until wrapWidth gets initialized so that height calculations
|
||||
// only happen once for these messages
|
||||
when(store, getWrapWidth, () => {
|
||||
if (env.messages) {
|
||||
if (env.messages) {
|
||||
// Wait until wrapWidth gets initialized so that height calculations
|
||||
// only happen once for these messages
|
||||
when(store, getWrapWidth, () => {
|
||||
const { messages, server, to, next } = env.messages;
|
||||
store.dispatch(addMessages(messages, server, to, false, next));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
export default async function initialState(ctx) {
|
||||
const env = await window.__init__;
|
||||
ctx.socket.connect();
|
||||
|
@ -59,7 +59,3 @@ export function setConnected(connected) {
|
||||
export function setCharWidth(width) {
|
||||
return appSet('charWidth', width);
|
||||
}
|
||||
|
||||
export function setConnectDefaults(defaults) {
|
||||
return appSet('connectDefaults', defaults);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user