display loader on initial load when loadingg defaultSafe
This commit is contained in:
parent
99fd7db46a
commit
c882c6ff5f
|
@ -1,8 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Switch, Redirect, Route } from 'react-router-dom'
|
import { Switch, Redirect, Route } from 'react-router-dom'
|
||||||
import { defaultSafeSelector } from '~/routes/safeList/store/selectors'
|
import { defaultSafeSelector } from '~/routes/safeList/store/selectors'
|
||||||
|
import Loader from '~/components/Loader'
|
||||||
import Welcome from './welcome/container'
|
import Welcome from './welcome/container'
|
||||||
import {
|
import {
|
||||||
SAFELIST_ADDRESS,
|
SAFELIST_ADDRESS,
|
||||||
|
@ -29,29 +30,40 @@ type RoutesProps = {
|
||||||
defaultSafe?: string,
|
defaultSafe?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Routes = ({ defaultSafe }: RoutesProps) => (
|
const Routes = ({ defaultSafe }: RoutesProps) => {
|
||||||
<Switch>
|
const [isInitialLoad, setIniitialLoad] = useState<boolean>(true)
|
||||||
<Route
|
|
||||||
exact
|
return (
|
||||||
path="/"
|
<Switch>
|
||||||
render={() => {
|
<Route
|
||||||
if (typeof defaultSafe === 'undefined') {
|
exact
|
||||||
return 'Loading...'
|
path="/"
|
||||||
}
|
render={() => {
|
||||||
if (defaultSafe) {
|
if (!isInitialLoad) {
|
||||||
return <Redirect to={`${SAFELIST_ADDRESS}/${defaultSafe}`} />
|
return <Redirect to={WELCOME_ADDRESS} />
|
||||||
}
|
}
|
||||||
return <Redirect to={WELCOME_ADDRESS} />
|
|
||||||
}}
|
if (typeof defaultSafe === 'undefined') {
|
||||||
/>
|
return <Loader />
|
||||||
<Route exact path={WELCOME_ADDRESS} component={Welcome} />
|
}
|
||||||
<Route exact path={OPEN_ADDRESS} component={Open} />
|
|
||||||
<Route exact path={SAFELIST_ADDRESS} component={SafeList} />
|
setIniitialLoad(false)
|
||||||
<Route exact path={SAFE_ADDRESS} component={Safe} />
|
if (defaultSafe) {
|
||||||
<Route exact path={OPENING_ADDRESS} component={Opening} />
|
return <Redirect to={`${SAFELIST_ADDRESS}/${defaultSafe}`} />
|
||||||
<Route exact path={LOAD_ADDRESS} component={Load} />
|
}
|
||||||
</Switch>
|
|
||||||
)
|
return <Redirect to={WELCOME_ADDRESS} />
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Route exact path={WELCOME_ADDRESS} component={Welcome} />
|
||||||
|
<Route exact path={OPEN_ADDRESS} component={Open} />
|
||||||
|
<Route exact path={SAFELIST_ADDRESS} component={SafeList} />
|
||||||
|
<Route exact path={SAFE_ADDRESS} component={Safe} />
|
||||||
|
<Route exact path={OPENING_ADDRESS} component={Opening} />
|
||||||
|
<Route exact path={LOAD_ADDRESS} component={Load} />
|
||||||
|
</Switch>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default connect<Object, Object, ?Function, ?Object>(
|
export default connect<Object, Object, ?Function, ?Object>(
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
|
Loading…
Reference in New Issue