diff options
Diffstat (limited to 'packages/website/ts/redux')
-rw-r--r-- | packages/website/ts/redux/dispatcher.ts | 12 | ||||
-rw-r--r-- | packages/website/ts/redux/reducer.ts | 19 |
2 files changed, 31 insertions, 0 deletions
diff --git a/packages/website/ts/redux/dispatcher.ts b/packages/website/ts/redux/dispatcher.ts index dea0a8bfe..c7e0a5af3 100644 --- a/packages/website/ts/redux/dispatcher.ts +++ b/packages/website/ts/redux/dispatcher.ts @@ -9,6 +9,7 @@ import { ProviderType, ScreenWidths, Side, + SideToAssetToken, SignatureData, Token, TokenStateByAddress, @@ -125,6 +126,17 @@ export class Dispatcher { type: ActionTypes.ClearTokenByAddress, }); } + public batchDispatch(tokens: Token[], networkId: number, userAddress: string, sideToAssetToken: SideToAssetToken) { + this._dispatch({ + data: { + tokens, + networkId, + userAddress, + sideToAssetToken, + }, + type: ActionTypes.BatchDispatch, + }); + } public updateTokenByAddress(tokens: Token[]) { this._dispatch({ data: tokens, diff --git a/packages/website/ts/redux/reducer.ts b/packages/website/ts/redux/reducer.ts index cee475fa9..427a8dd4a 100644 --- a/packages/website/ts/redux/reducer.ts +++ b/packages/website/ts/redux/reducer.ts @@ -181,6 +181,25 @@ 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, + }; + } + case ActionTypes.ForceTokenStateRefetch: return { ...state, |