From 1df3943d29099306394b1fb4fa4769dcf374d13b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 18 Aug 2026 16:28:31 +0000 Subject: [PATCH] fix(recept): uppdatera "Vad ska vi ata?" automatiskt nar lagret andras Nar man raderade varor i Matlager uppdaterades inte receptforslagen (coverage stod kvar pa t.ex. 50% tills man tvang-reloadade appen). Orsak: radering invaliderade inte ["what-to-eat"]-cachen. Cooking + scan-review gjorde redan detta; nu foljer kitchen (radering), barcode, meal-boxes och shopping samma monster sa forslagen alltid speglar aktuellt lager. --- apps/mobile/src/app/barcode.tsx | 1 + apps/mobile/src/app/kitchen.tsx | 2 ++ apps/mobile/src/app/meal-boxes.tsx | 1 + apps/mobile/src/app/shopping.tsx | 1 + 4 files changed, 5 insertions(+) diff --git a/apps/mobile/src/app/barcode.tsx b/apps/mobile/src/app/barcode.tsx index 4869369..bca0666 100644 --- a/apps/mobile/src/app/barcode.tsx +++ b/apps/mobile/src/app/barcode.tsx @@ -86,6 +86,7 @@ export default function BarcodeScreen() { }, }); await queryClient.invalidateQueries({ queryKey: ["inventory"] }); + await queryClient.invalidateQueries({ queryKey: ["what-to-eat"] }); router.back(); } catch (err) { Alert.alert(t("common.oops"), err instanceof Error ? err.message : t("common.error")); diff --git a/apps/mobile/src/app/kitchen.tsx b/apps/mobile/src/app/kitchen.tsx index d91eaeb..67a37c2 100644 --- a/apps/mobile/src/app/kitchen.tsx +++ b/apps/mobile/src/app/kitchen.tsx @@ -72,6 +72,8 @@ export default function KitchenScreen() { onSettled: () => { void queryClient.invalidateQueries({ queryKey: ["inventory"] }); void queryClient.invalidateQueries({ queryKey: ["inventory-expiring"] }); + // Lagret styr receptförslagen – uppdatera "Vad ska vi äta?" direkt. + void queryClient.invalidateQueries({ queryKey: ["what-to-eat"] }); }, }); diff --git a/apps/mobile/src/app/meal-boxes.tsx b/apps/mobile/src/app/meal-boxes.tsx index f92d4c4..ee087e9 100644 --- a/apps/mobile/src/app/meal-boxes.tsx +++ b/apps/mobile/src/app/meal-boxes.tsx @@ -56,6 +56,7 @@ export default function MealBoxesScreen() { onSuccess: async () => { await queryClient.invalidateQueries({ queryKey: ["meal-boxes"] }); await queryClient.invalidateQueries({ queryKey: ["inventory"] }); + await queryClient.invalidateQueries({ queryKey: ["what-to-eat"] }); await queryClient.invalidateQueries({ queryKey: ["day"] }); Alert.alert(t("common.done"), t("mealbox.undoSuccess")); }, diff --git a/apps/mobile/src/app/shopping.tsx b/apps/mobile/src/app/shopping.tsx index 60c7e34..9601f85 100644 --- a/apps/mobile/src/app/shopping.tsx +++ b/apps/mobile/src/app/shopping.tsx @@ -120,6 +120,7 @@ export default function ShoppingScreen() { onSuccess: async (result) => { const added = (result as { itemsAddedToInventory?: number }).itemsAddedToInventory ?? 0; await queryClient.invalidateQueries({ queryKey: ["inventory"] }); + await queryClient.invalidateQueries({ queryKey: ["what-to-eat"] }); invalidate(); Alert.alert(t("shopping.completedTitle"), t("shopping.completedBody", { count: added })); },