diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-03-17 01:21:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-17 01:21:21 +0800 |
commit | 00f1a2d78d01301f51157e9c8b8352dc0796d034 (patch) | |
tree | 91d9cbb8baa26efa462a86e9ecda460792f90996 /ui/app/components/ens-input.js | |
parent | 570cc891b5386dc04462737de4df6f2adf5059c9 (diff) | |
parent | a186e40d179d230fc1e81f7f507a5232d23ad462 (diff) | |
download | tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.gz tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.bz2 tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.lz tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.xz tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.tar.zst tangerine-wallet-browser-00f1a2d78d01301f51157e9c8b8352dc0796d034.zip |
Merge pull request #1198 from MetaMask/i1165-predictive
Add predictive address functionality to recipient field in send
Diffstat (limited to 'ui/app/components/ens-input.js')
-rw-r--r-- | ui/app/components/ens-input.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ui/app/components/ens-input.js b/ui/app/components/ens-input.js index ffc4eab4a..facf29d97 100644 --- a/ui/app/components/ens-input.js +++ b/ui/app/components/ens-input.js @@ -21,6 +21,7 @@ function EnsInput () { EnsInput.prototype.render = function () { const props = this.props const opts = extend(props, { + list: 'addresses', onChange: () => { const network = this.props.network let resolverAddress = networkResolvers[network] @@ -46,6 +47,25 @@ EnsInput.prototype.render = function () { style: { width: '100%' }, }, [ h('input.large-input', opts), + // The address book functionality. + h('datalist#addresses', + [ + // Corresponds to the addresses owned. + Object.keys(props.identities).map((key) => { + let identity = props.identities[key] + return h('option', { + value: identity.address, + label: identity.name, + }) + }), + // Corresponds to previously sent-to addresses. + props.addressBook.map((identity) => { + return h('option', { + value: identity.address, + label: identity.name, + }) + }), + ]), this.ensIcon(), ]) } @@ -80,11 +100,13 @@ EnsInput.prototype.lookupEnsName = function () { this.setState({ loadingEns: false, ensResolution: address, + nickname: recipient.trim(), hoverText: address + '\nClick to Copy', }) } }) .catch((reason) => { + log.error(reason) return this.setState({ loadingEns: false, ensFailure: true, @@ -95,10 +117,13 @@ EnsInput.prototype.lookupEnsName = function () { EnsInput.prototype.componentDidUpdate = function (prevProps, prevState) { const state = this.state || {} - const { ensResolution } = state + const ensResolution = state.ensResolution + // If an address is sent without a nickname, meaning not from ENS or from + // the user's own accounts, a default of a one-space string is used. + const nickname = state.nickname || ' ' if (ensResolution && this.props.onChange && ensResolution !== prevState.ensResolution) { - this.props.onChange(ensResolution) + this.props.onChange(ensResolution, nickname) } } |