diff --git a/frontend/app/components/Domain/Group/GroupPreferencesEditor.vue b/frontend/app/components/Domain/Group/GroupPreferencesEditor.vue index 5fdf51523..18862b912 100644 --- a/frontend/app/components/Domain/Group/GroupPreferencesEditor.vue +++ b/frontend/app/components/Domain/Group/GroupPreferencesEditor.vue @@ -42,4 +42,5 @@ import type { ReadGroupPreferences } from "~/lib/api/types/user"; const preferences = defineModel({ required: true }); const local = reactive({ ...preferences.value }); watch(local, (newVal) => { preferences.value = { ...newVal }; }); +watch(preferences, (newVal) => { if (newVal) Object.assign(local, newVal); }); diff --git a/frontend/app/components/Domain/Household/HouseholdPreferencesEditor.vue b/frontend/app/components/Domain/Household/HouseholdPreferencesEditor.vue index dc3205cc6..f17bbbb8d 100644 --- a/frontend/app/components/Domain/Household/HouseholdPreferencesEditor.vue +++ b/frontend/app/components/Domain/Household/HouseholdPreferencesEditor.vue @@ -63,6 +63,7 @@ import type { ReadHouseholdPreferences } from "~/lib/api/types/household"; const preferences = defineModel({ required: true }); const local = reactive({ ...preferences.value }); watch(local, (newVal) => { preferences.value = { ...newVal }; }); +watch(preferences, (newVal) => { if (newVal) Object.assign(local, newVal); }); const i18n = useI18n(); diff --git a/frontend/app/composables/use-households.ts b/frontend/app/composables/use-households.ts index 41dcbbe0c..20807c549 100644 --- a/frontend/app/composables/use-households.ts +++ b/frontend/app/composables/use-households.ts @@ -48,6 +48,9 @@ export const useHouseholdSelf = function () { return data || undefined; }, + async refresh() { + await refreshHouseholdSelf(); + }, }; const household = actions.get(); diff --git a/frontend/app/pages/group/index.vue b/frontend/app/pages/group/index.vue index 3569e983e..55d34e9ae 100644 --- a/frontend/app/pages/group/index.vue +++ b/frontend/app/pages/group/index.vue @@ -76,6 +76,14 @@ useSeoMeta({ title: i18n.t("group.group"), }); +// useGroupSelf() caches data in a module-level singleton for the lifetime of the tab, +// so revisiting this page via client-side navigation can otherwise show stale +// preferences/AI settings if they were changed elsewhere (e.g. Admin Groups panel) +// in the same session. Force a revalidation whenever this page is entered. +onMounted(() => { + groupActions.refresh(); +}); + const refGroupPrefsEditForm = ref(null); const refGroupAISettingsForm = ref(null); diff --git a/frontend/app/pages/household/index.vue b/frontend/app/pages/household/index.vue index 265bd3472..96480fce5 100644 --- a/frontend/app/pages/household/index.vue +++ b/frontend/app/pages/household/index.vue @@ -49,6 +49,14 @@ useSeoMeta({ title: i18n.t("household.household"), }); +// useHouseholdSelf() caches data in a module-level singleton for the lifetime of the tab, +// so revisiting this page via client-side navigation can otherwise show stale +// preferences if they were changed elsewhere (e.g. Admin Households panel) in the +// same session. Force a revalidation whenever this page is entered. +onMounted(() => { + householdActions.refresh(); +}); + const refHouseholdEditForm = ref(null); async function handleSubmit() { diff --git a/frontend/app/pages/household/mealplan/planner.vue b/frontend/app/pages/household/mealplan/planner.vue index d6ad1b96a..1c17dc3a5 100644 --- a/frontend/app/pages/household/mealplan/planner.vue +++ b/frontend/app/pages/household/mealplan/planner.vue @@ -116,12 +116,20 @@ const route = useRoute(); const router = useRouter(); const i18n = useI18n(); const api = useUserApi(); -const { household } = useHouseholdSelf(); +const { household, actions: householdActions } = useHouseholdSelf(); useSeoMeta({ title: i18n.t("meal-plan.dinner-this-week"), }); +// useHouseholdSelf() caches data in a module-level singleton for the lifetime of the tab, +// so revisiting this page via client-side navigation can otherwise use a stale +// firstDayOfWeek value if household preferences were changed elsewhere (e.g. Admin +// Households panel) in the same session. Force a revalidation whenever this page is entered. +onMounted(() => { + householdActions.refresh(); +}); + const mealPlanPreferences = useUserMealPlanPreferences(); const numberOfDaysPast = ref(mealPlanPreferences.value.numberOfDaysPast || 0); const numberOfDays = ref(mealPlanPreferences.value.numberOfDays || 7);