From 3c0ea9b208a5b6b4532fae2b990fd87ee802bb8c Mon Sep 17 00:00:00 2001 From: bl00dymarie Date: Fri, 23 Feb 2024 13:13:46 +0100 Subject: [PATCH] Turn fertility tracking off when mucus and cervix tracking are off --- local-storage.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/local-storage.js b/local-storage.js index 3647683..1c1759e 100644 --- a/local-storage.js +++ b/local-storage.js @@ -127,6 +127,14 @@ setObvWithInitValue('mucus', mucusTrackingCategoryObservable, true) export async function saveMucusTrackingCategory(bool) { await AsyncStorage.setItem('mucus', JSON.stringify(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() @@ -135,6 +143,14 @@ setObvWithInitValue('cervix', cervixTrackingCategoryObservable, true) export async function saveCervixTrackingCategory(bool) { await AsyncStorage.setItem('cervix', JSON.stringify(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()