aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-06-23 02:37:57 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-06-23 02:37:57 +0800
commit543f2c91fe3d00be33b2193eb88529a53622506a (patch)
tree85a74d2afdee64d964424f470767229dd744e789 /packages/website/ts
parent4375a0e07e2646d053a42aa5c852e9b2c3d8c110 (diff)
downloaddexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar.gz
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar.bz2
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar.lz
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar.xz
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.tar.zst
dexon-sol-tools-543f2c91fe3d00be33b2193eb88529a53622506a.zip
Pulled out reset AssetPicker state into a common variable
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/components/generate_order/asset_picker.tsx24
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);
}
}