Fix custom node removal crashing app

This commit is contained in:
HenryNguyen5 2018-02-08 18:49:58 -05:00
parent be88aaabb0
commit f7a9162279

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 { interface NodeLoaded {
pending: false; pending: false;
@ -27,12 +34,19 @@ const changeNodeIntent = (state: State, _: ChangeNodeIntentAction): State => ({
pending: true 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) { switch (action.type) {
case TypeKeys.CONFIG_NODE_CHANGE: case TypeKeys.CONFIG_NODE_CHANGE:
return changeNode(state, action); return changeNode(state, action);
case TypeKeys.CONFIG_NODE_CHANGE_INTENT: case TypeKeys.CONFIG_NODE_CHANGE_INTENT:
return changeNodeIntent(state, action); return changeNodeIntent(state, action);
case TypeKeys.CONFIG_REMOVE_CUSTOM_NODE:
return handleRemoveCustomNode(state, action);
default: default:
return state; return state;
} }