mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
show alert ONLY when device is connected
This commit is contained in:
parent
7cca146058
commit
bcbe7fef2e
@ -17,6 +17,7 @@ class ConnectHardwareForm extends Component {
|
|||||||
selectedAccount: null,
|
selectedAccount: null,
|
||||||
accounts: [],
|
accounts: [],
|
||||||
browserSupported: true,
|
browserSupported: true,
|
||||||
|
unlocked: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +33,14 @@ class ConnectHardwareForm extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async componentDidMount () {
|
componentDidMount () {
|
||||||
|
this.checkIfUnlocked()
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkIfUnlocked () {
|
||||||
const unlocked = await this.props.checkHardwareStatus('trezor')
|
const unlocked = await this.props.checkHardwareStatus('trezor')
|
||||||
if (unlocked) {
|
if (unlocked) {
|
||||||
|
this.setState({unlocked: true})
|
||||||
this.getPage(0)
|
this.getPage(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,12 +72,12 @@ class ConnectHardwareForm extends Component {
|
|||||||
if (accounts.length) {
|
if (accounts.length) {
|
||||||
|
|
||||||
// If we just loaded the accounts for the first time
|
// If we just loaded the accounts for the first time
|
||||||
// show the global alert
|
// (device previously locked) show the global alert
|
||||||
if (this.state.accounts.length === 0) {
|
if (this.state.accounts.length === 0 && !this.state.unlocked) {
|
||||||
this.showTemporaryAlert()
|
this.showTemporaryAlert()
|
||||||
}
|
}
|
||||||
|
|
||||||
const newState = {}
|
const newState = { unlocked: true }
|
||||||
// Default to the first account
|
// Default to the first account
|
||||||
if (this.state.selectedAccount === null) {
|
if (this.state.selectedAccount === null) {
|
||||||
accounts.forEach((a, i) => {
|
accounts.forEach((a, i) => {
|
||||||
@ -112,6 +118,7 @@ class ConnectHardwareForm extends Component {
|
|||||||
btnText: this.context.t('connectToTrezor'),
|
btnText: this.context.t('connectToTrezor'),
|
||||||
selectedAccount: null,
|
selectedAccount: null,
|
||||||
accounts: [],
|
accounts: [],
|
||||||
|
unlocked: false,
|
||||||
})
|
})
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.setState({ error: e.toString() })
|
this.setState({ error: e.toString() })
|
||||||
|
Loading…
Reference in New Issue
Block a user