mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #7326 from MetaMask/edit-contact
Edit contact details fix.
This commit is contained in:
commit
bed58dd7d9
@ -25,10 +25,16 @@ export default class EditContact extends PureComponent {
|
|||||||
setAccountLabel: PropTypes.func,
|
setAccountLabel: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
name: '',
|
||||||
|
address: '',
|
||||||
|
memo: '',
|
||||||
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
newName: '',
|
newName: this.props.name,
|
||||||
newAddress: '',
|
newAddress: this.props.address,
|
||||||
newMemo: '',
|
newMemo: this.props.memo,
|
||||||
error: '',
|
error: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +66,7 @@ export default class EditContact extends PureComponent {
|
|||||||
type="text"
|
type="text"
|
||||||
id="nickname"
|
id="nickname"
|
||||||
placeholder={this.context.t('addAlias')}
|
placeholder={this.context.t('addAlias')}
|
||||||
value={this.state.newName || name}
|
value={this.state.newName}
|
||||||
onChange={e => this.setState({ newName: e.target.value })}
|
onChange={e => this.setState({ newName: e.target.value })}
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="dense"
|
margin="dense"
|
||||||
@ -74,8 +80,7 @@ export default class EditContact extends PureComponent {
|
|||||||
<TextField
|
<TextField
|
||||||
type="text"
|
type="text"
|
||||||
id="address"
|
id="address"
|
||||||
placeholder={address}
|
value={this.state.newAddress}
|
||||||
value={this.state.newAddress || address}
|
|
||||||
error={this.state.error}
|
error={this.state.error}
|
||||||
onChange={e => this.setState({ newAddress: e.target.value })}
|
onChange={e => this.setState({ newAddress: e.target.value })}
|
||||||
fullWidth
|
fullWidth
|
||||||
@ -91,7 +96,7 @@ export default class EditContact extends PureComponent {
|
|||||||
type="text"
|
type="text"
|
||||||
id="memo"
|
id="memo"
|
||||||
placeholder={memo}
|
placeholder={memo}
|
||||||
value={this.state.newMemo || memo}
|
value={this.state.newMemo}
|
||||||
onChange={e => this.setState({ newMemo: e.target.value })}
|
onChange={e => this.setState({ newMemo: e.target.value })}
|
||||||
fullWidth
|
fullWidth
|
||||||
margin="dense"
|
margin="dense"
|
||||||
@ -110,12 +115,12 @@ export default class EditContact extends PureComponent {
|
|||||||
if (this.state.newAddress !== '' && this.state.newAddress !== address) {
|
if (this.state.newAddress !== '' && this.state.newAddress !== address) {
|
||||||
// if the user makes a valid change to the address field, remove the original address
|
// if the user makes a valid change to the address field, remove the original address
|
||||||
if (isValidAddress(this.state.newAddress)) {
|
if (isValidAddress(this.state.newAddress)) {
|
||||||
removeFromAddressBook(address)
|
removeFromAddressBook(chainId, address)
|
||||||
addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo)
|
addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo)
|
||||||
setAccountLabel(this.state.newAddress, this.state.newName || name)
|
setAccountLabel(this.state.newAddress, this.state.newName || name)
|
||||||
history.push(listRoute)
|
history.push(listRoute)
|
||||||
} else {
|
} else {
|
||||||
this.setState({ error: 'invalid address' })
|
this.setState({ error: this.context.t('invalidAddress') })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// update name
|
// update name
|
||||||
|
@ -98,6 +98,8 @@
|
|||||||
|
|
||||||
&--copy-icon {
|
&--copy-icon {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
|
width: 30px;
|
||||||
|
height: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user