Simplify calendar recalculate method

This commit is contained in:
Julia Friesel
2018-09-17 16:01:21 +02:00
parent d87a856754
commit d8c8f5034e
+5 -7
View File
@@ -18,19 +18,17 @@ export default class CalendarView extends Component {
todayInCalFormat: todayToCalFormat() todayInCalFormat: todayToCalFormat()
} }
this.setStateWithCalFormattedDays = (function (CalendarComponent) { this.bleedingDays.addListener(this.setStateWithCalFormattedDays)
return function() { }
setStateWithCalFormattedDays = () => {
const predictedMenses = cycleModule().getPredictedMenses() const predictedMenses = cycleModule().getPredictedMenses()
CalendarComponent.setState({ this.setState({
bleedingDaysInCalFormat: toCalFormat(this.bleedingDays), bleedingDaysInCalFormat: toCalFormat(this.bleedingDays),
predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses), predictedBleedingDaysInCalFormat: predictionToCalFormat(predictedMenses),
todayInCalFormat: todayToCalFormat() todayInCalFormat: todayToCalFormat()
}) })
} }
})(this)
this.bleedingDays.addListener(this.setStateWithCalFormattedDays)
}
componentWillUnmount() { componentWillUnmount() {
this.bleedingDays.removeListener(this.setStateWithCalFormattedDays) this.bleedingDays.removeListener(this.setStateWithCalFormattedDays)