Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
re-added back logic to remove wallet locked banner if unlocked mid ap…
Browse files Browse the repository at this point in the history
…p polling (#374)
  • Loading branch information
W3stside authored Sep 26, 2018
1 parent 5a7f27b commit c20fa51
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/containers/AppValidator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppValidator extends React.Component<any> {
state = {
online: inBrowser ? navigator.onLine : true,
loading: false,
SET_UP_COMPLETE: true,
set_up_complete: true,
error: '',
}

Expand All @@ -46,6 +46,7 @@ class AppValidator extends React.Component<any> {

// fire up app if user is actively connected to internet AND has provider set
if (this.state.online && activeProvider) {

// setTimeout condition if loading wallet takes too long
await Promise.race([
this.appMountSetup(),
Expand All @@ -54,7 +55,7 @@ class AppValidator extends React.Component<any> {

this.setState({
loading: false,
SET_UP_COMPLETE: true,
set_up_complete: true,
})
}

Expand All @@ -64,7 +65,7 @@ class AppValidator extends React.Component<any> {
} catch (error) {
this.setState({
loading: false,
SET_UP_COMPLETE: false,
set_up_complete: false,
error,
})
if (this.state.online) {
Expand All @@ -86,6 +87,8 @@ class AppValidator extends React.Component<any> {

// Detects any changes in Provider lock status or errors
componentWillReceiveProps(nextProps: any) {
const { set_up_complete } = this.state

if (nextProps.unlocked !== this.props.unlocked) {
console.log(`
Wallet lock status change detected.
Expand All @@ -94,9 +97,9 @@ class AppValidator extends React.Component<any> {
`)
// if app mount failed and nextProps detect an unlocked wallet
// reload the page
if (!this.state.error && !this.state.SET_UP_COMPLETE && nextProps.unlocked) {
if (!set_up_complete && !this.props.unlocked) {
// window.location.reload()
this.setState({ SET_UP_COMPLETE: true })
this.setState({ set_up_complete: true })
}
}
}
Expand Down Expand Up @@ -164,14 +167,14 @@ class AppValidator extends React.Component<any> {
}

renderError = () => {
const { error, loading, online, SET_UP_COMPLETE } = this.state,
const { error, loading, online, set_up_complete } = this.state,
{ disclaimer_accepted } = this.props
if (!disclaimer_accepted) return

return (
<>
{ (!online && !loading) && <h2 className="offlineBanner"> App is currently offline - please your check internet connection and refresh the page </h2> }
{ ((!SET_UP_COMPLETE && !loading) || (!this.props.unlocked && !loading)) && online && <h2 className="offlineBanner" style={{ backgroundColor: 'orange' }}> { error ? `App problems detected: ${error}` : 'App problems detected. Please check your provider and refresh the page.' } </h2> }
{ ((!set_up_complete && !loading) || (!this.props.unlocked && !loading)) && online && <h2 className="offlineBanner" style={{ backgroundColor: 'orange' }}> { error ? `App problems detected: ${error}` : 'App problems detected. Please check your provider and refresh the page.' } </h2> }
</>
)
}
Expand Down

0 comments on commit c20fa51

Please sign in to comment.