From b01fdbb4731007d82b03238cfa301d4e10ac7b23 Mon Sep 17 00:00:00 2001 From: tina <lt-bloody@riox.eu> Date: Sat, 15 Sep 2018 15:42:49 +0200 Subject: [PATCH] places todayString outside of reduce --- components/calendar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/calendar.js b/components/calendar.js index 13c466c0..95e8bf86 100644 --- a/components/calendar.js +++ b/components/calendar.js @@ -58,6 +58,7 @@ export default class CalendarView extends Component { } function toCalFormat(bleedingDaysSortedByDate) { + const todayDateString = LocalDate.now().toString() return bleedingDaysSortedByDate.reduce((acc, day) => { acc[day.date] = { customStyles: { @@ -66,7 +67,7 @@ function toCalFormat(bleedingDaysSortedByDate) { } } } - if (day.date === LocalDate.now().toString()) { + if (day.date === todayDateString) { acc[day.date].customStyles.text = styles.calendarToday } return acc @@ -75,6 +76,7 @@ function toCalFormat(bleedingDaysSortedByDate) { function predictionToCalFormat(predictedDays) { if (!predictedDays.length) return {} + const todayDateString = LocalDate.now().toString() const middleIndex = (predictedDays[0].length - 1) / 2 return predictedDays.reduce((acc, setOfDays) => { setOfDays.reduce((accSet, day, i) => { @@ -89,7 +91,7 @@ function predictionToCalFormat(predictedDays) { } } } - if (day === LocalDate.now().toString()) { + if (day === todayDateString) { accSet[day].customStyles.text = Object.assign( {}, styles.calendarToday, -- GitLab