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.
This commit is contained in:
parent
cade620623
commit
0ad348f7f5
1 changed files with 12 additions and 25 deletions
|
|
@ -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<TemporalFilter>(DEFAULT_FILTERS.temporal)
|
||||
const selectedCategories = ref<EventCategory[]>([])
|
||||
const selectedDate = ref<Date | undefined>(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<TemporalFilter>(DEFAULT_FILTERS.temporal)
|
||||
const selectedCategories = ref<EventCategory[]>([])
|
||||
const selectedDate = ref<Date | undefined>(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<EventFilters>(() => ({
|
||||
temporal: temporal.value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue