diff --git a/LeftOvers/screens/HomePage.tsx b/LeftOvers/screens/HomePage.tsx index 0dacb69..6a7cbf8 100644 --- a/LeftOvers/screens/HomePage.tsx +++ b/LeftOvers/screens/HomePage.tsx @@ -96,7 +96,7 @@ export default function HomePage({ navigation, props }) { }); useEffect(() => { - //AsyncStorage.clear() + AsyncStorage.clear() fetchProfiles(); if(profiles.length == 0){ setProfiles(profilesHand) diff --git a/LeftOvers/screens/IngredientSelection.tsx b/LeftOvers/screens/IngredientSelection.tsx index 15e180e..ce0e7da 100644 --- a/LeftOvers/screens/IngredientSelection.tsx +++ b/LeftOvers/screens/IngredientSelection.tsx @@ -120,6 +120,7 @@ const fetchAvailableIngredient = async () => { const updatedAvailableIngredient = [...existingAvailableIngredient, newIngredient]; await AsyncStorage.setItem('ingredient', JSON.stringify(updatedAvailableIngredient)); EventEmitter.emit('ingredientAdded'); + fetchAvailableIngredient(); console.log('Ingredient Added:', newIngredient); ChangeAvailableSize(false) } @@ -133,7 +134,6 @@ const fetchAvailableIngredient = async () => { try{ const updatedIngredients = selectedIngredients.filter((ingredient) => ingredient.id !== idIngredient); await AsyncStorage.setItem('ingredient', JSON.stringify(updatedIngredients)); - EventEmitter.emit('ingredientDeleted'); fetchAvailableIngredient(); setSelectedIngredients(updatedIngredients); ChangeAvailableSize(true) @@ -143,18 +143,6 @@ const fetchAvailableIngredient = async () => { } }; - const subscriptionAddIngredient = EventEmitter.addListener('ingredientAdded', async () => { - fetchAvailableIngredient(); - }); - const subscriptionDeleteIngredient = EventEmitter.addListener('ingredientDeleted', async () => { - if (selectedIngredients.length == 1){ - setSelectedIngredients([{title: "None"}]) - } - else{ - fetchAvailableIngredient(); - } - }); - const ChangeAvailableSize = (remove: boolean) => { if(remove){ if (selectedIngredients.length == 1){