detect ability to open popup instead of browser

feature/default_network_editable
brunobar79 6 years ago
parent d23227dc4f
commit 82a93bb287
  1. 12
      ui/app/components/pages/create-account/connect-hardware/connect-screen.js
  2. 5
      ui/app/components/pages/create-account/connect-hardware/index.js

@ -16,9 +16,11 @@ class ConnectScreen extends Component {
]),
h(
'button.btn-primary.btn--large',
{ onClick: () => global.platform.openWindow({
{
onClick: () => global.platform.openWindow({
url: 'https://google.com/chrome',
}), style: { margin: 12 } },
}),
},
this.context.t('downloadGoogleChrome')
),
])
@ -49,8 +51,7 @@ class ConnectScreen extends Component {
}
render () {
const isChrome = window.navigator.userAgent.search('Chrome') !== -1
if (isChrome) {
if (this.props.browserSupported) {
return this.renderConnectScreen()
}
return this.renderUnsupportedBrowser()
@ -59,7 +60,8 @@ class ConnectScreen extends Component {
ConnectScreen.propTypes = {
connectToTrezor: PropTypes.func.isRequired,
btnText: PropTypes.string,
btnText: PropTypes.string.isRequired,
browserSupported: PropTypes.bool.isRequired,
}
ConnectScreen.contextTypes = {

@ -16,6 +16,7 @@ class ConnectHardwareForm extends Component {
btnText: context.t('connectToTrezor'),
selectedAccount: null,
accounts: [],
browserSupported: true,
}
}
@ -78,6 +79,9 @@ class ConnectHardwareForm extends Component {
}
})
.catch(e => {
if (e === 'Window blocked') {
this.setState({ browserSupported: false })
}
this.setState({ btnText: this.context.t('connectToTrezor') })
})
}
@ -125,6 +129,7 @@ class ConnectHardwareForm extends Component {
return h(ConnectScreen, {
connectToTrezor: this.connectToTrezor,
btnText: this.state.btnText,
browserSupported: this.state.browserSupported,
})
}

Loading…
Cancel
Save