address selector: use cached reverses
This commit is contained in:
parent
b38aa8d01f
commit
6f492a4945
@ -56,6 +56,7 @@ class AddressSelect extends Component {
|
||||
contacts: PropTypes.object,
|
||||
contracts: PropTypes.object,
|
||||
tokens: PropTypes.object,
|
||||
reverse: PropTypes.object,
|
||||
|
||||
// Optional props
|
||||
allowCopy: PropTypes.bool,
|
||||
@ -584,10 +585,12 @@ class AddressSelect extends Component {
|
||||
function mapStateToProps (state) {
|
||||
const { accountsInfo } = state.personal;
|
||||
const { balances } = state.balances;
|
||||
const { reverse } = state.registry;
|
||||
|
||||
return {
|
||||
accountsInfo,
|
||||
balances
|
||||
balances,
|
||||
reverse
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,29 @@ export default class AddressSelectStore {
|
||||
@observable registryValues = [];
|
||||
|
||||
initValues = [];
|
||||
regLookups = [];
|
||||
regLookups = [
|
||||
(address) => {
|
||||
const name = this.reverse[address];
|
||||
|
||||
if (!name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
address,
|
||||
name,
|
||||
description: (
|
||||
<FormattedMessage
|
||||
id='addressSelect.fromRegistry'
|
||||
defaultMessage='{name} (from registry)'
|
||||
values={ {
|
||||
name
|
||||
} }
|
||||
/>
|
||||
)
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
constructor (api) {
|
||||
this.api = api;
|
||||
@ -114,7 +136,8 @@ export default class AddressSelectStore {
|
||||
}
|
||||
|
||||
@action setValues (props) {
|
||||
const { accounts = {}, contracts = {}, contacts = {} } = props;
|
||||
const { accounts = {}, contracts = {}, contacts = {}, reverse = {} } = props;
|
||||
this.reverse = reverse;
|
||||
|
||||
const accountsN = Object.keys(accounts).length;
|
||||
const contractsN = Object.keys(contracts).length;
|
||||
|
Loading…
Reference in New Issue
Block a user