From 5a9005904cc07d74b7dd4ba237a582e2cb299a8d Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sun, 3 Sep 2017 15:22:25 +0300 Subject: [PATCH] refactored reducers --- react/src/reducers/addcoin.js | 5 +++-- react/src/reducers/atomic.js | 5 +++-- react/src/reducers/interval.js | 10 ++++++---- react/src/reducers/main.js | 20 ++++++++++++-------- react/src/reducers/settings.js | 30 ++++++++++++++++++------------ react/src/reducers/syncOnly.js | 10 ++++++---- 6 files changed, 48 insertions(+), 32 deletions(-) diff --git a/react/src/reducers/addcoin.js b/react/src/reducers/addcoin.js index 1f0a915..88e9024 100644 --- a/react/src/reducers/addcoin.js +++ b/react/src/reducers/addcoin.js @@ -8,10 +8,11 @@ export function AddCoin(state = { }, action) { switch (action.type) { case DISPLAY_ADDCOIN_MODAL: - return Object.assign({}, state, { + return { + ...state, display: action.display, isLogin: action.isLogin, - }); + }; default: return state; } diff --git a/react/src/reducers/atomic.js b/react/src/reducers/atomic.js index 073f7e6..a839bdb 100644 --- a/react/src/reducers/atomic.js +++ b/react/src/reducers/atomic.js @@ -7,9 +7,10 @@ export function Atomic(state = { }, action) { switch (action.type) { case ATOMIC: - return Object.assign({}, state, { + return { + ...state, response: action.response, - }); + }; default: return state; } diff --git a/react/src/reducers/interval.js b/react/src/reducers/interval.js index 10dca6f..af37259 100644 --- a/react/src/reducers/interval.js +++ b/react/src/reducers/interval.js @@ -12,15 +12,17 @@ export function Interval(state = { case START_INTERVAL: newIntervalState[action.name] = action.handle; - return Object.assign({}, state, { + return { + ...state, interval: newIntervalState, - }); + }; case STOP_INTERVAL: newIntervalState[action.name] = null; - return Object.assign({}, state, { + return { + ...state, interval: newIntervalState, - }); + }; default: return state; } diff --git a/react/src/reducers/main.js b/react/src/reducers/main.js index 0381ef1..bef5931 100644 --- a/react/src/reducers/main.js +++ b/react/src/reducers/main.js @@ -12,23 +12,27 @@ export function Main(state = { }, action) { switch (action.type) { case GET_ACTIVE_COINS: - return Object.assign({}, state, { + return { + ...state, activeCoins: action.activeCoins, coins: action.coins, - }); + }; case LOGIN: - return Object.assign({}, state, { + return { + ...state, isLoggedIn: action.isLoggedIn, - }); + }; case ACTIVE_HANDLE: - return Object.assign({}, state, { + return { + ...state, isLoggedIn: action.isLoggedIn, activeHandle: action.handle, - }); + }; case DISPLAY_LOGIN_SETTINGS_MODAL: - return Object.assign({}, state, { + return { + ...state, displayLoginSettingsModal: action.displayLoginSettingsModal, - }); + }; default: return state; } diff --git a/react/src/reducers/settings.js b/react/src/reducers/settings.js index 133cd96..e07f9dc 100644 --- a/react/src/reducers/settings.js +++ b/react/src/reducers/settings.js @@ -17,31 +17,37 @@ export function Settings(state = { }, action) { switch (action.type) { case GET_WIF_KEY: - return Object.assign({}, state, { + return { + ...state, wifkey: action.wifkey, address: action.address, - }); + }; case GET_PEERS_LIST: - return Object.assign({}, state, { + return { + ...state, supernetPeers: action.supernetPeers, rawPeers: action.rawPeers, - }); + }; case GET_DEBUG_LOG: - return Object.assign({}, state, { + return { + ...state, debugLog: action.data, - }); + }; case LOAD_APP_CONFIG: - return Object.assign({}, state, { + return { + ...state, appSettings: action.config, - }); + }; case LOAD_APP_INFO: - return Object.assign({}, state, { + return { + ...state, appInfo: action.info, - }); + }; case CLI: - return Object.assign({}, state, { + return { + ...state, cli: action.data, - }); + }; default: return state; } diff --git a/react/src/reducers/syncOnly.js b/react/src/reducers/syncOnly.js index c1fecfb..5896431 100644 --- a/react/src/reducers/syncOnly.js +++ b/react/src/reducers/syncOnly.js @@ -9,13 +9,15 @@ export function SyncOnly(state = { }, action) { switch (action.type) { case SYNC_ONLY_MODAL_TOGGLE: - return Object.assign({}, state, { + return { + ...state, display: action.display, - }); + }; case SYNC_ONLY_DATA: - return Object.assign({}, state, { + return { + ...state, forks: action.forks, - }); + }; default: return state; }