MyCrypto/common/reducers/config/networks/customNetworks.ts
Daniel Ternyak c9676cac62
Deterministic Webpack 4 (#1445)
* (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
2018-04-05 15:53:36 -05:00

30 lines
853 B
TypeScript

import {
AddCustomNetworkAction,
RemoveCustomNetworkAction,
CustomNetworkAction,
TypeKeys
} from 'actions/config';
import { CustomNetworksState as State } from './types';
const addCustomNetwork = (state: State, { payload }: AddCustomNetworkAction): State => ({
...state,
[payload.id]: payload.config
});
function removeCustomNetwork(state: State, { payload }: RemoveCustomNetworkAction): State {
const stateCopy = { ...state };
Reflect.deleteProperty(stateCopy, payload.id);
return stateCopy;
}
export const customNetworks = (state: State = {}, action: CustomNetworkAction) => {
switch (action.type) {
case TypeKeys.CONFIG_ADD_CUSTOM_NETWORK:
return addCustomNetwork(state, action);
case TypeKeys.CONFIG_REMOVE_CUSTOM_NETWORK:
return removeCustomNetwork(state, action);
default:
return state;
}
};