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.
This commit is contained in:
Claude
2026-08-18 16:28:31 +00:00
parent 3942890d6f
commit 1df3943d29
4 changed files with 5 additions and 0 deletions
+1
View File
@@ -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"));
+2
View File
@@ -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"] });
},
});
+1
View File
@@ -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"));
},
+1
View File
@@ -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 }));
},