When navigating to cycle day, remember origin
This commit is contained in:
@@ -29,6 +29,10 @@ export default class App extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigate = (pageName, props) => {
|
navigate = (pageName, props) => {
|
||||||
|
const curr = this.state.currentPage
|
||||||
|
if (navigatingToCycleDayFromMainMenuEntry(pageName, curr)) {
|
||||||
|
this.cycleDayOrigin = curr
|
||||||
|
}
|
||||||
this.setState({currentPage: pageName, currentProps: props})
|
this.setState({currentPage: pageName, currentProps: props})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +40,9 @@ export default class App extends Component {
|
|||||||
if (this.state.currentPage === 'Home') return false
|
if (this.state.currentPage === 'Home') return false
|
||||||
if (isSymptomView(this.state.currentPage)) {
|
if (isSymptomView(this.state.currentPage)) {
|
||||||
this.navigate('CycleDay', { cycleDay: this.state.currentProps.cycleDay })
|
this.navigate('CycleDay', { cycleDay: this.state.currentProps.cycleDay })
|
||||||
|
} else if(this.state.currentPage === 'CycleDay') {
|
||||||
|
this.navigate(this.cycleDayOrigin || 'Home')
|
||||||
|
this.cycleDayOrigin = null
|
||||||
} else {
|
} else {
|
||||||
this.navigate('Home')
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user