Browse Source

Merge pull request #781 from gre/fix-go-back-on-dashboard-after-reset

Fix going back on Portfolio after a reset
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
352e196d1c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/components/App.js
  2. 2
      src/components/Onboarding/index.js
  3. 28
      src/components/OnboardingOrElse.js
  4. 1
      src/helpers/hardReset.js
  5. 2
      src/reducers/settings.js

18
src/components/App.js

@ -12,8 +12,7 @@ import theme from 'styles/theme'
import i18n from 'renderer/i18n/electron'
import Onboarding from 'components/Onboarding'
import OnboardingOrElse from 'components/OnboardingOrElse'
import ThrowBlock from 'components/ThrowBlock'
import Default from 'components/layout/Default'
import Print from 'components/layout/Print'
@ -35,13 +34,14 @@ const App = ({
<I18nextProvider i18n={i18n} initialLanguage={language}>
<ThemeProvider theme={theme}>
<ThrowBlock>
<Onboarding />
<ConnectedRouter history={history}>
<Switch>
<Route path="/print" component={Print} />
<Route component={Default} />
</Switch>
</ConnectedRouter>
<OnboardingOrElse>
<ConnectedRouter history={history}>
<Switch>
<Route path="/print" component={Print} />
<Route component={Default} />
</Switch>
</ConnectedRouter>
</OnboardingOrElse>
</ThrowBlock>
</ThemeProvider>
</I18nextProvider>

2
src/components/Onboarding/index.js

@ -24,6 +24,7 @@ import { getCurrentDevice } from 'reducers/devices'
import { unlock } from 'reducers/application'
import Box from 'components/base/Box'
import TriggerAppReady from '../TriggerAppReady'
import Start from './steps/Start'
import InitStep from './steps/Init'
@ -147,6 +148,7 @@ class Onboarding extends PureComponent<Props> {
return (
<Container>
<TriggerAppReady />
{step.options.showBreadcrumb && <OnboardingBreadcrumb />}
<StepContainer>
<StepComponent {...stepProps} />

28
src/components/OnboardingOrElse.js

@ -0,0 +1,28 @@
// @flow
import React, { PureComponent } from 'react'
import { connect } from 'react-redux'
import { createStructuredSelector } from 'reselect'
import { hasCompletedOnboardingSelector } from 'reducers/settings'
import Onboarding from './Onboarding'
type Props = {
hasCompletedOnboarding: boolean,
children: *,
}
class OnboardingOrElse extends PureComponent<Props> {
render() {
const { hasCompletedOnboarding, children } = this.props
if (hasCompletedOnboarding) {
return children
}
return <Onboarding />
}
}
export default connect(
createStructuredSelector({
hasCompletedOnboarding: hasCompletedOnboardingSelector,
}),
)(OnboardingOrElse)

1
src/helpers/hardReset.js

@ -9,4 +9,5 @@ export default async function hardReset() {
disableDBMiddleware()
db.resetAll()
await delay(500)
window.location.href = ''
}

2
src/reducers/settings.js

@ -223,5 +223,7 @@ export const marketIndicatorSelector = (state: State) => state.settings.marketIn
export const sentryLogsBooleanSelector = (state: State) => state.settings.sentryLogs
export const shareAnalyticsSelector = (state: State) => state.settings.shareAnalytics
export const selectedTimeRangeSelector = (state: State) => state.settings.selectedTimeRange
export const hasCompletedOnboardingSelector = (state: State) =>
state.settings.hasCompletedOnboarding
export default handleActions(handlers, INITIAL_STATE)

Loading…
Cancel
Save