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:
@@ -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"));
|
||||
|
||||
@@ -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"] });
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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"));
|
||||
},
|
||||
|
||||
@@ -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 }));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user