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 { 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 { addMessages } from 'state/messages';
|
||||||
import { setSettings } from 'state/settings';
|
import { setSettings } from 'state/settings';
|
||||||
import { when } from 'utils/observe';
|
import { when } from 'utils/observe';
|
||||||
|
|
||||||
function loadState({ store }, env) {
|
function loadState({ store }, env) {
|
||||||
store.dispatch(setConnectDefaults(env.defaults));
|
|
||||||
store.dispatch(setSettings(env.settings, true));
|
store.dispatch(setSettings(env.settings, true));
|
||||||
|
|
||||||
if (env.servers) {
|
if (env.servers) {
|
||||||
@ -33,22 +30,24 @@ function loadState({ store }, env) {
|
|||||||
|
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
appSet({
|
appSet({
|
||||||
|
connectDefaults: env.defaults,
|
||||||
initialized: true,
|
initialized: true,
|
||||||
hexIP: env.hexIP,
|
hexIP: env.hexIP,
|
||||||
version: env.version
|
version: env.version
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Wait until wrapWidth gets initialized so that height calculations
|
if (env.messages) {
|
||||||
// only happen once for these messages
|
// Wait until wrapWidth gets initialized so that height calculations
|
||||||
when(store, getWrapWidth, () => {
|
// only happen once for these messages
|
||||||
if (env.messages) {
|
when(store, getWrapWidth, () => {
|
||||||
const { messages, server, to, next } = env.messages;
|
const { messages, server, to, next } = env.messages;
|
||||||
store.dispatch(addMessages(messages, server, to, false, next));
|
store.dispatch(addMessages(messages, server, to, false, next));
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable no-underscore-dangle */
|
||||||
export default async function initialState(ctx) {
|
export default async function initialState(ctx) {
|
||||||
const env = await window.__init__;
|
const env = await window.__init__;
|
||||||
ctx.socket.connect();
|
ctx.socket.connect();
|
||||||
|
@ -59,7 +59,3 @@ export function setConnected(connected) {
|
|||||||
export function setCharWidth(width) {
|
export function setCharWidth(width) {
|
||||||
return appSet('charWidth', width);
|
return appSet('charWidth', width);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setConnectDefaults(defaults) {
|
|
||||||
return appSet('connectDefaults', defaults);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user