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

Simplify calendar recalculate method

parent d87a8567
No related branches found
No related tags found
No related merge requests found
......@@ -18,20 +18,18 @@ export default class CalendarView extends Component {
todayInCalFormat: todayToCalFormat()
}
this.setStateWithCalFormattedDays = (function (CalendarComponent) {
return function() {
const predictedMenses = cycleModule().getPredictedMenses()
CalendarComponent.setState({
bleedingDaysInCalFormat: toCalFormat(this.bleedingDays),
predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses),
todayInCalFormat: todayToCalFormat()
})
}
})(this)
this.bleedingDays.addListener(this.setStateWithCalFormattedDays)
}
setStateWithCalFormattedDays = () => {
const predictedMenses = cycleModule().getPredictedMenses()
this.setState({
bleedingDaysInCalFormat: toCalFormat(this.bleedingDays),
predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses),
todayInCalFormat: todayToCalFormat()
})
}
componentWillUnmount() {
this.bleedingDays.removeListener(this.setStateWithCalFormattedDays)
}
......
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