@ -1,4 +1,4 @@
import React from 'react'
import React , { Component } from 'react'
import { connect } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import { Switch , Route } from 'react-router'
@ -29,6 +29,7 @@ import {
updateRecoverSeedInput ,
setReEnterSeedIndexes
} from 'reducers/onboarding'
import { fetchTicker , tickerSelectors } from 'reducers/ticker'
import { lndSelectors } from 'reducers/lnd'
import { walletAddress } from 'reducers/address'
import LoadingBolt from 'components/LoadingBolt'
@ -60,7 +61,8 @@ const mapDispatchToProps = {
walletAddress ,
updateReEnterSeedInput ,
updateRecoverSeedInput ,
setReEnterSeedIndexes
setReEnterSeedIndexes ,
fetchTicker
}
const mapStateToProps = state => ( {
@ -69,7 +71,8 @@ const mapStateToProps = state => ({
address : state . address ,
info : state . info ,
theme : state . settings . theme ,
balance : state . balance ,
currentTicker : tickerSelectors . currentTicker ( state ) ,
syncPercentage : lndSelectors . syncPercentage ( state ) ,
passwordIsValid : onboardingSelectors . passwordIsValid ( state ) ,
passwordMinCharsError : onboardingSelectors . passwordMinCharsError ( state ) ,
@ -208,47 +211,64 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
}
}
const Root = ( { history , lnd , onboardingProps , syncingProps } ) => {
// If we are have not yet onboarded, show the loading/onboarding screen.
if ( ! onboardingProps . onboarding . onboarded ) {
return (
< div >
< LoadingBolt
theme = { onboardingProps . theme }
visible = { ! onboardingProps . onboarding . onboarding }
/ >
< Onboarding { ... onboardingProps } / >
< Syncing { ... syncingProps } / >
< / d i v >
)
class Root extends Component {
componentWillMount ( ) {
const { fetchTicker } = this . props
fetchTicker ( )
}
// If we are syncing show the syncing screen.
if (
lnd . lightningGrpcActive &&
onboardingProps . onboarding . connectionType === 'local' &&
lnd . syncStatus !== 'complete'
) {
return < Syncing { ... syncingProps } / >
}
render ( ) {
const { balance , currentTicker , history , lnd , onboardingProps , syncingProps } = this . props
// Don't launch the app without a connection to lnd.
if ( ! lnd . lightningGrpcActive && ! lnd . walletUnlockerGrpcActive ) {
return < LoadingBolt theme = { onboardingProps . theme } / >
}
if ( ! onboardingProps . onboarding . onboarded ) {
return (
< div >
< LoadingBolt
theme = { onboardingProps . theme }
visible = { ! onboardingProps . onboarding . onboarding }
/ >
< Onboarding { ... onboardingProps } / >
< Syncing { ... syncingProps } / >
< / d i v >
)
}
// If we are syncing show the syncing screen.
if (
lnd . lightningGrpcActive &&
onboardingProps . onboarding . connectionType === 'local' &&
lnd . syncStatus !== 'complete'
) {
return < Syncing { ... syncingProps } / >
}
return (
< ConnectedRouter history = { history } >
< App >
< Switch >
< Route path = "/" component = { Activity } / >
< / S w i t c h >
< / A p p >
< / C o n n e c t e d R o u t e r >
)
return (
< ConnectedRouter history = { history } >
< div >
< LoadingBolt
theme = { onboardingProps . theme }
visible = {
( ! lnd . lightningGrpcActive && ! lnd . walletUnlockerGrpcActive ) ||
! currentTicker ||
balance . channelBalance === null ||
balance . walletBalance === null
}
/ >
< App >
< Switch >
< Route path = "/" component = { Activity } / >
< / S w i t c h >
< / A p p >
< / d i v >
< / C o n n e c t e d R o u t e r >
)
}
}
Root . propTypes = {
balance : PropTypes . object . isRequired ,
fetchTicker : PropTypes . func . isRequired ,
currentTicker : PropTypes . object ,
history : PropTypes . object . isRequired ,
lnd : PropTypes . object . isRequired ,
onboardingProps : PropTypes . object . isRequired ,