Fix input addr crash (#1799)

This commit is contained in:
Jaco Greeff 2019-10-29 08:32:04 +01:00 committed by GitHub
parent 7fbe334e94
commit 6596f4eda4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -11,7 +11,7 @@ import styled from 'styled-components';
import { AccountName } from '@polkadot/react-query';
import { KeyringItemType } from '@polkadot/ui-keyring/types';
import { classes } from './util';
import { classes, toShortAddress } from './util';
import BalanceDisplay from './Balance';
import BondedDisplay from './Bonded';
import IdentityIcon from './IdentityIcon';
@ -30,10 +30,11 @@ interface Props extends BareProps {
withBalance?: boolean;
withBonded?: boolean;
withLockedVote?: boolean;
withName?: boolean;
}
function AddressMini (props: Props): React.ReactElement<Props> | null {
const { balance, bonded, children, className, iconInfo, isPadded = true, style, value, withAddress = true, withBalance = false, withBonded = false, withLockedVote = false } = props;
const { balance, bonded, children, className, iconInfo, isPadded = true, style, value, withAddress = true, withBalance = false, withBonded = false, withLockedVote = false, withName = true } = props;
if (!value) {
return null;
@ -49,7 +50,10 @@ function AddressMini (props: Props): React.ReactElement<Props> | null {
<div className='ui--AddressMini-info'>
{withAddress && (
<div className='ui--AddressMini-address'>
<AccountName params={address} />
{withName
? <AccountName params={address} />
: toShortAddress(address)
}
</div>
)}
{children}

View File

@ -256,7 +256,7 @@ class InputAddress extends React.PureComponent<Props, State> {
const queryLower = query.toLowerCase();
const matches = filteredOptions.filter((item): boolean =>
item.value !== null && (
item.name.toLowerCase().includes(queryLower) ||
(item.name.toLowerCase && item.name.toLowerCase().includes(queryLower)) ||
item.value.toLowerCase().includes(queryLower)
)
);

View File

@ -68,7 +68,7 @@ function signerIconName (status: QueueTxStatus): any {
function renderStatus ({ account, action, id, message, removeItem, status }: QueueStatus): React.ReactNode {
const addressRendered = account
? <AddressMini value={account} />
? <AddressMini value={account} withName={false} />
: undefined;
return (