From 49bd61c9cf2c6fc3a0c7606515b1b6ef9680f25d Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 21 Nov 2017 16:42:10 -0600 Subject: [PATCH] fix(syncing): move syncing logic out of application component --- app/containers/Root.js | 48 +++++++++++++++++++++++++------- app/routes.js | 2 +- app/routes/app/components/App.js | 20 +++---------- 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/containers/Root.js b/app/containers/Root.js index 7e38493a..14bd76a6 100644 --- a/app/containers/Root.js +++ b/app/containers/Root.js @@ -1,20 +1,48 @@ // @flow import React from 'react' -import { Provider } from 'react-redux' +import { Provider, connect } from 'react-redux' import { ConnectedRouter } from 'react-router-redux' +import { fetchBlockHeight, lndSelectors } from 'reducers/lnd' +import LndSyncing from 'components/LndSyncing' import Routes from '../routes' +const mapDispatchToProps = { + fetchBlockHeight +} + +const mapStateToProps = state => ({ + syncPercentage: lndSelectors.syncPercentage(state) +}) + type RootType = { store: {}, history: {} }; -export default function Root({ store, history }: RootType) { - return ( - - - - - - ) -} +class Root extends React.Component { + render() { + const { store, history, fetchBlockHeight, syncPercentage } = this.props + const { lnd } = store.getState() + + if (lnd.syncing) { + return ( + + ) + } + + return ( + + + + + + ) + } +} + + +export default connect(mapStateToProps, mapDispatchToProps)(Root) \ No newline at end of file diff --git a/app/routes.js b/app/routes.js index d700389d..52bcaf6a 100644 --- a/app/routes.js +++ b/app/routes.js @@ -14,4 +14,4 @@ export default () => ( -); +) diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index c2677bef..df379315 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -13,12 +13,10 @@ class App extends Component { componentWillMount() { const { fetchTicker, fetchBalance, fetchInfo, newAddress, lnd: { syncing } } = this.props - if (!syncing) { - fetchTicker() - fetchBalance() - fetchInfo() - newAddress('p2pkh') - } + fetchTicker() + fetchBalance() + fetchInfo() + newAddress('p2pkh') } render() { @@ -47,16 +45,6 @@ class App extends Component { children } = this.props - if (lnd.syncing) { - return ( - - ) - } - if (!currentTicker || balance.balanceLoading) { return } return (