diff --git a/components/app.js b/components/app.js index 827b11e390b9eecdc7fb91bd1a2f7352470243de..ba58437096a47e00b570711426339362f3cba2f4 100644 --- a/components/app.js +++ b/components/app.js @@ -29,6 +29,10 @@ export default class App extends Component { } navigate = (pageName, props) => { + const curr = this.state.currentPage + if (navigatingToCycleDayFromMainMenuEntry(pageName, curr)) { + this.cycleDayOrigin = curr + } this.setState({currentPage: pageName, currentProps: props}) } @@ -36,6 +40,9 @@ export default class App extends Component { if (this.state.currentPage === 'Home') return false if (isSymptomView(this.state.currentPage)) { this.navigate('CycleDay', { cycleDay: this.state.currentProps.cycleDay }) + } else if(this.state.currentPage === 'CycleDay') { + this.navigate(this.cycleDayOrigin || 'Home') + this.cycleDayOrigin = null } else { this.navigate('Home') } @@ -63,3 +70,7 @@ export default class App extends Component { ) } } + +function navigatingToCycleDayFromMainMenuEntry(target, curr) { + return target === 'CycleDay' && ['Home', 'Calendar', 'Chart'].indexOf(curr) > -1 +} \ No newline at end of file