diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-06-23 02:37:57 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-06-23 02:37:57 +0800 |
commit | 543f2c91fe3d00be33b2193eb88529a53622506a (patch) | |
tree | 85a74d2afdee64d964424f470767229dd744e789 /packages/website | |
parent | 4375a0e07e2646d053a42aa5c852e9b2c3d8c110 (diff) | |
download | dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar.gz dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar.bz2 dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar.lz dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar.xz dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.tar.zst dexon-0x-contracts-543f2c91fe3d00be33b2193eb88529a53622506a.zip |
Pulled out reset AssetPicker state into a common variable
Diffstat (limited to 'packages/website')
-rw-r--r-- | packages/website/ts/components/generate_order/asset_picker.tsx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/packages/website/ts/components/generate_order/asset_picker.tsx b/packages/website/ts/components/generate_order/asset_picker.tsx index 738692264..87618f1e0 100644 --- a/packages/website/ts/components/generate_order/asset_picker.tsx +++ b/packages/website/ts/components/generate_order/asset_picker.tsx @@ -232,12 +232,14 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt this.props.onTokenChosen(newToken.address); } private async _onTrackConfirmationRespondedAsync(didUserAcceptTracking: boolean): Promise<void> { + const resetState: AssetPickerState = { + ...this.state, + isAddingTokenToTracked: false, + assetView: AssetViews.ASSET_PICKER, + chosenTrackTokenAddress: undefined, + }; if (!didUserAcceptTracking) { - this.setState({ - isAddingTokenToTracked: false, - assetView: AssetViews.ASSET_PICKER, - chosenTrackTokenAddress: undefined, - }); + this.setState(resetState); this._onCloseDialog(); return; } @@ -247,11 +249,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt const tokenAddress = this.state.chosenTrackTokenAddress; const token = this.props.tokenByAddress[tokenAddress]; if (_.isUndefined(tokenAddress)) { - this.setState({ - isAddingTokenToTracked: false, - assetView: AssetViews.ASSET_PICKER, - chosenTrackTokenAddress: undefined, - }); + this.setState(resetState); return; } const newTokenEntry = { @@ -262,11 +260,7 @@ export class AssetPicker extends React.Component<AssetPickerProps, AssetPickerSt trackedTokenStorage.addTrackedTokenToUser(this.props.userAddress, this.props.networkId, newTokenEntry); this.props.dispatcher.updateTokenByAddress([newTokenEntry]); - this.setState({ - isAddingTokenToTracked: false, - assetView: AssetViews.ASSET_PICKER, - chosenTrackTokenAddress: undefined, - }); + this.setState(resetState); this.props.onTokenChosen(tokenAddress); } } |