From 75ec28b4dc0aa1fc8515efa1bc82503a741ec54b Mon Sep 17 00:00:00 2001 From: Padreug Date: Tue, 16 Jun 2026 11:50:47 +0200 Subject: [PATCH] fix(events): refresh owned tickets after purchase (no reload needed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a successful ticket purchase, the feed/calendar "My tickets" filter and EventCard owned badges didn't update until a full page reload — the shared useOwnedTickets singleton was never refreshed. Its own docs note a successful purchase should call refresh(); wire that in at the payment- confirmed point in useTicketPurchase so every surface reflects the new ticket immediately. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/modules/events/composables/useTicketPurchase.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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