mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-01 13:55:50 +00:00
c9676cac62
* (Reapplied) Upgrade to Webpack 4 * remove yarn.lock from gitignore * add yarn.lock * custom hashing for css and client bundle filenames * add hash-files dep * update deps * add .wwp-cache to .gitignore * use latest git hash as filename hash * remove unused hash-files dep * update favicon plugin * remove yarn.lock
30 lines
818 B
TypeScript
30 lines
818 B
TypeScript
import {
|
|
TypeKeys,
|
|
CustomNodeAction,
|
|
AddCustomNodeAction,
|
|
RemoveCustomNodeAction
|
|
} from 'actions/config';
|
|
import { CustomNodesState as State } from './types';
|
|
|
|
const addCustomNode = (state: State, { payload }: AddCustomNodeAction): State => ({
|
|
...state,
|
|
[payload.id]: payload.config
|
|
});
|
|
|
|
function removeCustomNode(state: State, { payload }: RemoveCustomNodeAction): State {
|
|
const stateCopy = { ...state };
|
|
Reflect.deleteProperty(stateCopy, payload.id);
|
|
return stateCopy;
|
|
}
|
|
|
|
export const customNodes = (state: State = {}, action: CustomNodeAction): State => {
|
|
switch (action.type) {
|
|
case TypeKeys.CONFIG_ADD_CUSTOM_NODE:
|
|
return addCustomNode(state, action);
|
|
case TypeKeys.CONFIG_REMOVE_CUSTOM_NODE:
|
|
return removeCustomNode(state, action);
|
|
default:
|
|
return state;
|
|
}
|
|
};
|