Fix: Sets isCycleStart to false when bleeding value gets deleted
This commit is contained in:
+1
-1
@@ -90,7 +90,7 @@ export function saveSymptom(symptom, date, val) {
|
||||
let cycleDay = getCycleDay(date)
|
||||
if (!cycleDay) cycleDay = createCycleDay(date)
|
||||
db.write(() => {
|
||||
if (symptom === 'bleeding' && val != null && val.value != null) {
|
||||
if (symptom === 'bleeding' && val && val.value != null) {
|
||||
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
|
||||
maybeSetNewCycleStart({
|
||||
val,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
export default function ({
|
||||
val, cycleDay, mensesDaysAfter, checkIsMensesStart
|
||||
val,
|
||||
cycleDay,
|
||||
mensesDaysAfter,
|
||||
checkIsMensesStart,
|
||||
}) {
|
||||
|
||||
cycleDay.bleeding = val
|
||||
|
||||
// if a bleeding value is deleted or excluded, we need to check if there are
|
||||
@@ -20,15 +22,15 @@ export default function ({
|
||||
}
|
||||
|
||||
function bleedingValueDeletedOrExluded(val) {
|
||||
const bleedingDeleted = !val
|
||||
const bleedingDeleted = !val || (val && !(typeof val.value === 'number'))
|
||||
const bleedingExcluded = val && val.exclude
|
||||
return bleedingDeleted || bleedingExcluded
|
||||
}
|
||||
|
||||
function maybeClearOldCycleStarts() {
|
||||
// if we have a new bleeding day, we need to clear the
|
||||
// menses start marker from all following days of this
|
||||
// menses that may have been marked as start before
|
||||
mensesDaysAfter.forEach(day => day.isCycleStart = false)
|
||||
// if we have a new bleeding day, we need to clear the
|
||||
// menses start marker from all following days of this
|
||||
// menses that may have been marked as start before
|
||||
mensesDaysAfter.forEach((day) => (day.isCycleStart = false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user