diff --git a/db/index.js b/db/index.js index 5c838dc..4fb6240 100644 --- a/db/index.js +++ b/db/index.js @@ -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, diff --git a/lib/set-new-cycle-start.js b/lib/set-new-cycle-start.js index 34b5a69..ab61cde 100644 --- a/lib/set-new-cycle-start.js +++ b/lib/set-new-cycle-start.js @@ -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)) } -} \ No newline at end of file +}