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