fix(instant): render token selector when only one asset is available

This commit is contained in:
Brandon Millman 2018-12-03 16:36:27 -08:00
parent 2601d16efb
commit e592b27f77
2 changed files with 6 additions and 5 deletions

View File

@ -113,7 +113,7 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput
); );
}; };
private readonly _renderChevronIcon = (): React.ReactNode => { private readonly _renderChevronIcon = (): React.ReactNode => {
if (!this._areMultipleAssetsAvailable()) { if (!this._areAnyAssetsAvailable()) {
return null; return null;
} }
return ( return (
@ -134,14 +134,14 @@ export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInput
// We don't want to allow opening the token selection panel if there are no assets. // We don't want to allow opening the token selection panel if there are no assets.
// Since styles are inferred from the presence of a click handler, we want to return undefined // Since styles are inferred from the presence of a click handler, we want to return undefined
// instead of providing a noop. // instead of providing a noop.
if (!this._areMultipleAssetsAvailable() || _.isUndefined(this.props.onSelectAssetClick)) { if (!this._areAnyAssetsAvailable() || _.isUndefined(this.props.onSelectAssetClick)) {
return undefined; return undefined;
} }
return this._handleSelectAssetClick; return this._handleSelectAssetClick;
}; };
private readonly _areMultipleAssetsAvailable = (): boolean => { private readonly _areAnyAssetsAvailable = (): boolean => {
const { numberOfAssetsAvailable } = this.props; const { numberOfAssetsAvailable } = this.props;
return !_.isUndefined(numberOfAssetsAvailable) && numberOfAssetsAvailable > 1; return !_.isUndefined(numberOfAssetsAvailable) && numberOfAssetsAvailable > 0;
}; };
private readonly _handleSelectAssetClick = (): void => { private readonly _handleSelectAssetClick = (): void => {
if (this.props.onSelectAssetClick) { if (this.props.onSelectAssetClick) {

View File

@ -32,7 +32,8 @@ export const asyncData = {
const assetBuyer = providerState.assetBuyer; const assetBuyer = providerState.assetBuyer;
try { try {
const assetDatas = await assetBuyer.getAvailableAssetDatasAsync(); const assetDatas = await assetBuyer.getAvailableAssetDatasAsync();
const assets = assetUtils.createAssetsFromAssetDatas(assetDatas, assetMetaDataMap, network); const deduplicatedAssetDatas = _.uniq(assetDatas);
const assets = assetUtils.createAssetsFromAssetDatas(deduplicatedAssetDatas, assetMetaDataMap, network);
dispatch(actions.setAvailableAssets(assets)); dispatch(actions.setAvailableAssets(assets));
} catch (e) { } catch (e) {
const errorMessage = 'Could not find any assets'; const errorMessage = 'Could not find any assets';