Simplify calendar recalculate method

This commit is contained in:
Julia Friesel
2018-09-17 16:01:21 +02:00
parent d87a856754
commit d8c8f5034e
+9 -11
View File
@@ -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)
}