Move cervix & mucus off turn fertility off logic out of local storage

This commit is contained in:
bl00dymarie
2024-02-23 16:38:44 +01:00
parent 5855ea0a34
commit 1c73509473
2 changed files with 2 additions and 16 deletions
@@ -173,6 +173,8 @@ const Settings = () => {
setIsSecondarySymptomDisabled(false) setIsSecondarySymptomDisabled(false)
} else if (!cervix && !mucus) { } else if (!cervix && !mucus) {
setIsSecondarySymptomDisabled(true) setIsSecondarySymptomDisabled(true)
setFertilityTrackingEnabled(false)
saveFertilityTrackingEnabled(false)
} }
setMucusTrackingCategory(mucus) setMucusTrackingCategory(mucus)
saveMucusTrackingCategory(mucus) saveMucusTrackingCategory(mucus)
-16
View File
@@ -121,14 +121,6 @@ setObvWithInitValue('mucus', mucusTrackingCategoryObservable, true)
export async function saveMucusTrackingCategory(bool) { export async function saveMucusTrackingCategory(bool) {
await AsyncStorage.setItem('mucus', JSON.stringify(bool)) await AsyncStorage.setItem('mucus', JSON.stringify(bool))
mucusTrackingCategoryObservable.set(bool) mucusTrackingCategoryObservable.set(bool)
// if mucus and cervix tracking is turned off, the fertility tracking gets disabled
if (!mucusTrackingCategoryObservable.value && !cervixTrackingCategoryObservable.value) {
const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking')
if (fertilityTrackingResult) {
saveFertilityTrackingEnabled(false)
}
}
} }
export const cervixTrackingCategoryObservable = Observable() export const cervixTrackingCategoryObservable = Observable()
@@ -137,14 +129,6 @@ setObvWithInitValue('cervix', cervixTrackingCategoryObservable, true)
export async function saveCervixTrackingCategory(bool) { export async function saveCervixTrackingCategory(bool) {
await AsyncStorage.setItem('cervix', JSON.stringify(bool)) await AsyncStorage.setItem('cervix', JSON.stringify(bool))
cervixTrackingCategoryObservable.set(bool) cervixTrackingCategoryObservable.set(bool)
// if cervix and mucus tracking is turned off, the fertility tracking gets disabled
if (!cervixTrackingCategoryObservable.value && !mucusTrackingCategoryObservable.value) {
const fertilityTrackingResult = await AsyncStorage.getItem('fertilityTracking')
if (fertilityTrackingResult) {
saveFertilityTrackingEnabled(false)
}
}
} }
export const sexTrackingCategoryObservable = Observable() export const sexTrackingCategoryObservable = Observable()