Fix custom node removal crashing app

This commit is contained in:
HenryNguyen5 2018-02-08 18:49:58 -05:00
parent be88aaabb0
commit f7a9162279
1 changed files with 16 additions and 2 deletions

View File

@ -1,4 +1,11 @@
import { ChangeNodeAction, ChangeNodeIntentAction, NodeAction, TypeKeys } from 'actions/config';
import {
ChangeNodeAction,
ChangeNodeIntentAction,
NodeAction,
TypeKeys,
RemoveCustomNodeAction,
CustomNodeAction
} from 'actions/config';
interface NodeLoaded {
pending: false;
@ -27,12 +34,19 @@ const changeNodeIntent = (state: State, _: ChangeNodeIntentAction): State => ({
pending: true
});
export const selectedNode = (state: State = INITIAL_STATE, action: NodeAction) => {
const handleRemoveCustomNode = (state: State, _: RemoveCustomNodeAction): State => INITIAL_STATE;
export const selectedNode = (
state: State = INITIAL_STATE,
action: NodeAction | CustomNodeAction
) => {
switch (action.type) {
case TypeKeys.CONFIG_NODE_CHANGE:
return changeNode(state, action);
case TypeKeys.CONFIG_NODE_CHANGE_INTENT:
return changeNodeIntent(state, action);
case TypeKeys.CONFIG_REMOVE_CUSTOM_NODE:
return handleRemoveCustomNode(state, action);
default:
return state;
}