From df7ab30dc53edec8ea798a32b1bd8e4ad76dcf5d Mon Sep 17 00:00:00 2001 From: Padreug Date: Thu, 4 Jun 2026 22:37:03 +0200 Subject: [PATCH] fix(activities): share filter refs across useActivities consumers useActivityFilters allocated a fresh set of refs on every call, so when activities-app/App.vue (Hosting bottom-nav tab) and ActivitiesPage.vue each invoked useActivities(), they got independent onlyHosting/temporal/etc state. Tapping Hosting toggled the App.vue ref; the page never saw the change. Hoist the filter refs to module scope so every consumer shares the same instance. --- .../composables/useActivityFilters.ts | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/modules/activities/composables/useActivityFilters.ts b/src/modules/activities/composables/useActivityFilters.ts index 8f9914b..a5ae1da 100644 --- a/src/modules/activities/composables/useActivityFilters.ts +++ b/src/modules/activities/composables/useActivityFilters.ts @@ -8,35 +8,22 @@ import type { ActivityCategory } from '../types/category' import type { TemporalFilter, ActivityFilters } from '../types/filters' import { DEFAULT_FILTERS } from '../types/filters' +// Filter state is hoisted to module scope so every `useActivities()` / +// `useActivityFilters()` call shares the same refs. The bottom-nav +// Hosting tab in activities-app/App.vue and the feed view in +// ActivitiesPage.vue both rely on this — without a shared instance, +// tapping Hosting toggled a private ref the page never saw. +const temporal = ref(DEFAULT_FILTERS.temporal) +const selectedCategories = ref([]) +const selectedDate = ref(undefined) +const onlyOwnedTickets = ref(false) +const onlyHosting = ref(false) +const showPast = ref(false) + /** * Composable for managing activity filter state and applying filters reactively. */ export function useActivityFilters() { - const temporal = ref(DEFAULT_FILTERS.temporal) - const selectedCategories = ref([]) - const selectedDate = ref(undefined) - /** - * When true, the feed is narrowed to activities the current user - * holds at least one paid ticket for. Crossed with the - * `ownedActivityIds` set from useOwnedTickets in useActivities - * (this composable stays free of ticket fetching). - */ - const onlyOwnedTickets = ref(false) - /** - * When true, the feed is narrowed to activities the current user - * is hosting (organizer pubkey matches the signed-in user, or the - * row is a local LNbits draft of theirs). Reads `activity.isMine` - * which `useActivities.tagOwnership()` populates. - */ - const onlyHosting = ref(false) - /** - * When false (default), activities that have already ended are - * hidden from the feed. Toggling on includes them so the user can - * browse past events. The date-picker overrides this — picking a - * specific past date shows that day's activities regardless, - * mirroring how it overrides the temporal pills. - */ - const showPast = ref(false) const filters = computed(() => ({ temporal: temporal.value,