diff --git a/src/modules/events/composables/useTicketPurchase.ts b/src/modules/events/composables/useTicketPurchase.ts index 4d4dc45..5c3df37 100644 --- a/src/modules/events/composables/useTicketPurchase.ts +++ b/src/modules/events/composables/useTicketPurchase.ts @@ -5,12 +5,19 @@ import { useAsyncOperation } from '@/core/composables/useAsyncOperation' import { injectService, SERVICE_TOKENS } from '@/core/di-container' import type { PaymentService } from '@/core/services/PaymentService' import type { TicketApiService } from '../services/TicketApiService' +import { useOwnedTickets } from './useOwnedTickets' export function useTicketPurchase() { const { isAuthenticated, currentUser } = useAuth() const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as PaymentService const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService + // Refresh the shared owned-tickets singleton after a purchase so the + // feed/calendar "My tickets" filter and EventCard owned badges update + // without a reload — purchase is exactly the "consumer that mutates + // the ticket set" useOwnedTickets's docs anticipate. + const { refresh: refreshOwnedTickets } = useOwnedTickets() + // Async operations const purchaseOperation = useAsyncOperation() @@ -178,6 +185,12 @@ export function useTicketPurchase() { clearInterval(checkInterval) } + // Ticket row(s) now exist — refresh the shared owned-tickets + // state so the feed/calendar My-tickets filter and owned + // badges reflect the purchase immediately (no reload). Runs in + // parallel with QR generation below. + void refreshOwnedTickets() + // Multi-ticket purchases come back with `ticketIds` (N rows // sharing one invoice). Single-ticket purchases include // `ticketId` only. Render one QR per row so each attendee