From 85419ea5faf555b682213ff19f690fd2121b3c5c 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. --- .../events/composables/useEventFilters.ts | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/modules/events/composables/useEventFilters.ts b/src/modules/events/composables/useEventFilters.ts index 5f9379c..71ce1ff 100644 --- a/src/modules/events/composables/useEventFilters.ts +++ b/src/modules/events/composables/useEventFilters.ts @@ -8,35 +8,22 @@ import type { EventCategory } from '../types/category' import type { TemporalFilter, EventFilters } from '../types/filters' import { DEFAULT_FILTERS } from '../types/filters' +// Filter state is hoisted to module scope so every `useEvents()` / +// `useEventFilters()` call shares the same refs. The bottom-nav +// Hosting tab in events-app/App.vue and the feed view in +// EventsPage.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 event filter state and applying filters reactively. */ export function useEventFilters() { - const temporal = ref(DEFAULT_FILTERS.temporal) - const selectedCategories = ref([]) - const selectedDate = ref(undefined) - /** - * When true, the feed is narrowed to events the current user - * holds at least one paid ticket for. Crossed with the - * `ownedEventIds` set from useOwnedTickets in useEvents - * (this composable stays free of ticket fetching). - */ - const onlyOwnedTickets = ref(false) - /** - * When true, the feed is narrowed to events the current user - * is hosting (organizer pubkey matches the signed-in user, or the - * row is a local LNbits draft of theirs). Reads `event.isMine` - * which `useEvents.tagOwnership()` populates. - */ - const onlyHosting = ref(false) - /** - * When false (default), events 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 events regardless, - * mirroring how it overrides the temporal pills. - */ - const showPast = ref(false) const filters = computed(() => ({ temporal: temporal.value,