Skip to content

Commit

Permalink
Clean up for the loading-network-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Dec 12, 2018
1 parent f4dc649 commit 04cc98d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
6 changes: 6 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,9 @@
"sigRequested": {
"message": "Signature Requested"
},
"somethingWentWrong": {
"message": "Oops! Something went wrong."
},
"spaceBetween": {
"message": "there can only be a space between words"
},
Expand All @@ -1219,6 +1222,9 @@
"speedUpTransaction": {
"message": "Speed up this transaction"
},
"switchNetworks": {
"message": "Switch Networks"
},
"status": {
"message": "Status"
},
Expand Down
3 changes: 1 addition & 2 deletions ui/app/components/loading-network-screen/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
const LoadingNetworksScreen = require('./loading-network-screen.container')
module.exports = LoadingNetworksScreen
export { default } from './loading-network-screen.container'
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import React, { Component } from 'react'
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import Spinner from '../spinner'
import Button from '../button'

class LoadingNetworkScreen extends Component {
constructor (props) {
super(props)

this.state = {
showErrorScreen: false,
}
export default class LoadingNetworkScreen extends PureComponent {
state = {
showErrorScreen: false,
}

static contextTypes = {
t: PropTypes.func,
}

componentWillMount = () => {
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 3000)
static propTypes = {
loadingMessage: PropTypes.string,
cancelTime: PropTypes.number,
provider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
providerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
showNetworkDropdown: PropTypes.func,
setProviderArgs: PropTypes.array,
lastSelectedProvider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
setProviderType: PropTypes.func,
isLoadingNetwork: PropTypes.bool,
}

componentDidMount = () => {
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 15000)
}

getConnectingLabel = function (loadingMessage) {
Expand Down Expand Up @@ -60,7 +68,7 @@ class LoadingNetworkScreen extends Component {

return <div className="loading-overlay__error-screen">
<span className="loading-overlay__emoji">&#128542;</span>
<span>Oops! Something went wrong.</span>
<span>{ this.context.t('somethingWentWrong') }</span>
<div className="loading-overlay__error-buttons">
<Button
type="default"
Expand All @@ -69,7 +77,7 @@ class LoadingNetworkScreen extends Component {
showNetworkDropdown()
}}
>
{ 'Switch Networks' }
{ this.context.t('switchNetworks') }
</Button>

<Button
Expand All @@ -78,10 +86,10 @@ class LoadingNetworkScreen extends Component {
this.setState({ showErrorScreen: false })
setProviderType(...setProviderArgs)
window.clearTimeout(this.cancelCallTimeout)
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 3000)
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 15000)
}}
>
{ 'Try Again' }
{ this.context.t('tryAgain') }
</Button>
</div>
</div>
Expand All @@ -101,7 +109,7 @@ class LoadingNetworkScreen extends Component {
if (provider.type !== prevProvider.type) {
window.clearTimeout(this.cancelCallTimeout)
this.setState({ showErrorScreen: false })
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 3000)
this.cancelCallTimeout = setTimeout(this.cancelCall, this.props.cancelTime || 15000)
}
}

Expand All @@ -128,18 +136,3 @@ class LoadingNetworkScreen extends Component {
)
}
}

LoadingNetworkScreen.propTypes = {
loadingMessage: PropTypes.string,
cancelTime: PropTypes.number,
provider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
providerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
showNetworkDropdown: PropTypes.func,
setProviderArgs: PropTypes.array,
lastSelectedProvider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
setProviderType: PropTypes.func,
isLoadingNetwork: PropTypes.bool,

}

module.exports = LoadingNetworkScreen
1 change: 0 additions & 1 deletion ui/app/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function getNetworkIdentifier (state) {
const { metamask: { provider: { type, nickname, rpcTarget } } } = state

return nickname || rpcTarget || type

}

function getSelectedAddress (state) {
Expand Down

0 comments on commit 04cc98d

Please sign in to comment.