fix(reducers): remove initial state from reducers

This commit is contained in:
Kirill Shumilov
2016-06-27 17:26:52 +03:00
parent d57d637421
commit ee7bc84dfd
6 changed files with 12 additions and 34 deletions

View File

@@ -1,9 +1,6 @@
import initialState from '../state';
export const editor = (state, action) => {
const newState = (state === undefined) ? initialState.editor : state;
export const editor = (state = {}, action) => {
switch (action.type) {
default:
return newState;
return state;
}
};

View File

@@ -1,4 +1,3 @@
import initialState from '../state';
import { LINK_ADD, LINK_DELETE } from '../actionTypes';
import R from 'ramda';
@@ -24,8 +23,7 @@ const link = (state, action) => {
}
};
export const links = (state, action) => {
const newState = (state === undefined) ? initialState.project.links : state;
export const links = (state = {}, action) => {
let newLink = null;
let newLinkId = 0;
@@ -38,6 +36,6 @@ export const links = (state, action) => {
case LINK_DELETE:
return R.omit([action.payload.id.toString()], state);
default:
return newState;
return state;
}
};

View File

@@ -1,5 +1,4 @@
import { NODE_MOVE, NODE_ADD, NODE_DELETE } from '../actionTypes';
import initialState from '../state';
import R from 'ramda';
const nodeIds = (nodes) =>
@@ -26,9 +25,7 @@ const node = (state, action) => {
}
};
export const nodes = (state, action) => {
const newState = (state === undefined) ? R.clone(initialState.project.nodes) : state;
export const nodes = (state = {}, action) => {
let movedNode = null;
let newNode = null;
let newNodeId = 0;
@@ -49,6 +46,6 @@ export const nodes = (state, action) => {
return R.set(R.lensProp(action.payload.id), movedNode, state);
default:
return newState;
return state;
}
};

View File

@@ -1,11 +1,6 @@
import initialState from '../state';
import R from 'ramda';
export const nodeTypes = (state, action) => {
const newState = (state === undefined) ? R.clone(initialState.nodeTypes) : state;
export const nodeTypes = (state = {}, action) => {
switch (action.type) {
default:
return newState;
return state;
}
};

View File

@@ -1,11 +1,6 @@
import initialState from '../state';
import R from 'ramda';
export const patches = (state, action) => {
const newState = (state === undefined) ? R.clone(initialState.project.patches) : state;
export const patches = (state = {}, action) => {
switch (action.type) {
default:
return newState;
return state;
}
};

View File

@@ -1,10 +1,6 @@
import initialState from '../state';
import R from 'ramda';
export const pins = (state, action) => {
const newState = (state === undefined) ? R.clone(initialState.project.pins) : state;
export const pins = (state = {}, action) => {
switch (action.type) {
default:
return newState;
return state;
}
};