Fix labels and clean up code
This commit is contained in:
+2
-2
@@ -65,6 +65,7 @@ export function getBleedingDaysSortedByDate() {
|
||||
return db
|
||||
.objects('CycleDay')
|
||||
.filtered('bleeding != null')
|
||||
.filtered('bleeding.value != null')
|
||||
.sorted('date', true)
|
||||
}
|
||||
export function getTemperatureDaysSortedByDate() {
|
||||
@@ -88,9 +89,8 @@ export function getCycleStartsSortedByDate() {
|
||||
export function saveSymptom(symptom, date, val) {
|
||||
let cycleDay = getCycleDay(date)
|
||||
if (!cycleDay) cycleDay = createCycleDay(date)
|
||||
|
||||
db.write(() => {
|
||||
if (symptom === 'bleeding') {
|
||||
if (symptom === 'bleeding' && val != null && val.value != null) {
|
||||
const mensesDaysAfter = getMensesDaysRightAfter(cycleDay)
|
||||
maybeSetNewCycleStart({
|
||||
val,
|
||||
|
||||
+4
-3
@@ -17,7 +17,7 @@ const TemperatureSchema = {
|
||||
const BleedingSchema = {
|
||||
name: 'Bleeding',
|
||||
properties: {
|
||||
value: 'int',
|
||||
value: { type: 'int', optional: true },
|
||||
exclude: 'bool',
|
||||
pad: { type: 'bool', optional: true },
|
||||
tampon: { type: 'bool', optional: true },
|
||||
@@ -26,6 +26,7 @@ const BleedingSchema = {
|
||||
softTampon: { type: 'bool', optional: true },
|
||||
none: { type: 'bool', optional: true },
|
||||
other: { type: 'bool', optional: true },
|
||||
note: { type: 'string', optional: true },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -174,11 +175,10 @@ export default {
|
||||
schemaVersion: 5,
|
||||
migration: (oldRealm, newRealm) => {
|
||||
if (oldRealm.schemaVersion < 5) {
|
||||
const oldObjects = oldRealm.objects('Bleeding')
|
||||
const newObjects = newRealm.objects('Bleeding')
|
||||
|
||||
// loop through all objects and assign a default value for new properties
|
||||
for (let i = 0; i < oldObjects.length; i++) {
|
||||
for (let i = 0; i < newObjects.length; i++) {
|
||||
newObjects[i].pad = false
|
||||
newObjects[i].tampon = false
|
||||
newObjects[i].underwear = false
|
||||
@@ -186,6 +186,7 @@ export default {
|
||||
newObjects[i].softTampon = false
|
||||
newObjects[i].none = false
|
||||
newObjects[i].other = false
|
||||
newObjects[i].note = null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user