From 86cc011212088801a778d947ae925cc0b1ddadf8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 30 Jan 2018 11:16:13 +0100 Subject: Wholesale replace the tokenByAddress and de-dup properly --- packages/website/ts/redux/dispatcher.ts | 10 ++++++++-- packages/website/ts/redux/reducer.ts | 11 +---------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'packages/website/ts/redux') diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index 9df18e54c..aae7683ff 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -12,6 +12,7 @@ import { SideToAssetToken, SignatureData, Token, + TokenByAddress, TokenStateByAddress, } from 'ts/types'; @@ -121,10 +122,15 @@ export class Dispatcher { type: ActionTypes.RemoveTokenFromTokenByAddress, }); } - public batchDispatch(tokens: Token[], networkId: number, userAddress: string, sideToAssetToken: SideToAssetToken) { + public batchDispatch( + tokenByAddress: TokenByAddress, + networkId: number, + userAddress: string, + sideToAssetToken: SideToAssetToken, + ) { this._dispatch({ data: { - tokens, + tokenByAddress, networkId, userAddress, sideToAssetToken, diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index f94da003f..4b5a9138f 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -175,21 +175,12 @@ export function reducer(state: State = INITIAL_STATE, action: Action) { } case ActionTypes.BatchDispatch: { - const tokenByAddress = state.tokenByAddress; - const tokens = action.data.tokens; - _.each(tokens, token => { - const updatedToken = { - ...tokenByAddress[token.address], - ...token, - }; - tokenByAddress[token.address] = updatedToken; - }); return { ...state, networkId: action.data.networkId, userAddress: action.data.userAddress, sideToAssetToken: action.data.sideToAssetToken, - tokenByAddress, + tokenByAddress: action.data.tokenByAddress, }; } -- cgit v1.2.3