From 6577038f2277621dadcbe022c5884b38d56af971 Mon Sep 17 00:00:00 2001 From: emelko Date: Thu, 25 Apr 2019 10:58:04 +0200 Subject: [PATCH] Rename to predictedBleeding --- components/home.js | 28 ++++++++++++++-------------- lib/notifications.js | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/components/home.js b/components/home.js index 8aa5183..f2b5414 100644 --- a/components/home.js +++ b/components/home.js @@ -182,22 +182,22 @@ export default class Home extends Component { function determinePredictionText(bleedingPrediction) { if (!bleedingPrediction.length) return predictLabels.noPrediction const todayDate = LocalDate.now() - const bleedingStart = LocalDate.parse(bleedingPrediction[0][0]) - const bleedingEnd = LocalDate.parse( + const predictedBleedingStart = LocalDate.parse(bleedingPrediction[0][0]) + const predictedBleedingEnd = LocalDate.parse( bleedingPrediction[0][ bleedingPrediction[0].length - 1 ] ) - if (todayDate.isBefore(bleedingStart)) { + if (todayDate.isBefore(predictedBleedingStart)) { return predictLabels.predictionInFuture( - todayDate.until(bleedingStart, ChronoUnit.DAYS), - todayDate.until(bleedingEnd, ChronoUnit.DAYS) + todayDate.until(predictedBleedingStart, ChronoUnit.DAYS), + todayDate.until(predictedBleedingEnd, ChronoUnit.DAYS) ) } - if (todayDate.isAfter(bleedingEnd)) { + if (todayDate.isAfter(predictedBleedingEnd)) { return predictLabels.predictionInPast( - dateForShortDescription(bleedingStart), dateForShortDescription(bleedingEnd) + dateForShortDescription(predictedBleedingStart), dateForShortDescription(predictedBleedingEnd) ) } - const daysToEnd = todayDate.until(bleedingEnd, ChronoUnit.DAYS) + const daysToEnd = todayDate.until(predictedBleedingEnd, ChronoUnit.DAYS) if (daysToEnd === 0) { return predictLabels.predictionStartedNoDaysLeft } else if (daysToEnd === 1) { @@ -210,15 +210,15 @@ function determinePredictionText(bleedingPrediction) { function getBleedingPredictionRange(prediction) { if (!prediction.length) return labels.unknown const todayDate = LocalDate.now() - const bleedingStart = LocalDate.parse(prediction[0][0]) - const bleedingEnd = LocalDate.parse(prediction[0][ prediction[0].length - 1 ]) - if (todayDate.isBefore(bleedingStart)) { - return `${todayDate.until(bleedingStart, ChronoUnit.DAYS)}-${todayDate.until(bleedingEnd, ChronoUnit.DAYS)}` + const predictedBleedingStart = LocalDate.parse(prediction[0][0]) + const predictedBleedingEnd = LocalDate.parse(prediction[0][ prediction[0].length - 1 ]) + if (todayDate.isBefore(predictedBleedingStart)) { + return `${todayDate.until(predictedBleedingStart, ChronoUnit.DAYS)}-${todayDate.until(predictedBleedingEnd, ChronoUnit.DAYS)}` } - if (todayDate.isAfter(bleedingEnd)) { + if (todayDate.isAfter(predictedBleedingEnd)) { return labels.unknown } - const daysToEnd = todayDate.until(bleedingEnd, ChronoUnit.DAYS) + const daysToEnd = todayDate.until(predictedBleedingEnd, ChronoUnit.DAYS) if (daysToEnd === 0) { return '0' } else { diff --git a/lib/notifications.js b/lib/notifications.js index 9836a37..1692484 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -58,9 +58,9 @@ export default function setupNotifications(navigate) { function setupPeriodReminder() { const bleedingPrediction = cycleModule().getPredictedMenses() if (bleedingPrediction.length > 0) { - const bleedingStart = Moment(bleedingPrediction[0][0], "YYYY-MM-DD") + const predictedBleedingStart = Moment(bleedingPrediction[0][0], "YYYY-MM-DD") // 3 days before and at 6 am - const reminderDate = bleedingStart + const reminderDate = predictedBleedingStart .subtract(3, 'days') .hours(6) .minutes(0)