Skip to content
Snippets Groups Projects
Commit 8bb0d1ca authored by Julia Friesel's avatar Julia Friesel
Browse files

Merge branch '236-bug-pressing-back-from-day-view-doesnt-work' into 'master'

Resolve "bug: pressing back from day view doesnt work"

Closes #236

See merge request bloodyhealth/drip!104
parents 2a476b1f ef6d42fe
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,8 @@ const menuTitlesLowerCase = Object.keys(menuTitles).reduce((acc, curr) => {
return acc
}, {})
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
const isSymptomView = name => Object.keys(symptomViews).includes(name)
const isMenuItem = name => Object.keys(menuTitles).includes(name)
export default class App extends Component {
constructor(props) {
......@@ -40,7 +41,14 @@ export default class App extends Component {
}
navigate = (pageName, props) => {
this.origin = this.state.currentPage
// for the back button to work properly, we want to
// remember two origins: which menu item we came from
// and from where we navigated to the symptom view (day
// view or home page)
if (isMenuItem(this.state.currentPage)) {
this.menuOrigin = this.state.currentPage
}
this.originForSymptomView = this.state.currentPage
this.setState({currentPage: pageName, currentProps: props})
}
......@@ -48,10 +56,10 @@ export default class App extends Component {
if (this.state.currentPage === 'Home') return false
if (isSymptomView(this.state.currentPage)) {
this.navigate(
this.origin, { cycleDay: this.state.currentProps.cycleDay }
this.originForSymptomView, { cycleDay: this.state.currentProps.cycleDay }
)
} else if(this.state.currentPage === 'CycleDay') {
this.navigate(this.origin)
this.navigate(this.menuOrigin)
} else {
this.navigate('Home')
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment