fix(events): refresh owned tickets after purchase (no reload needed)
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) <noreply@anthropic.com>
This commit is contained in:
parent
c6ed247031
commit
75ec28b4dc
1 changed files with 13 additions and 0 deletions
|
|
@ -5,12 +5,19 @@ import { useAsyncOperation } from '@/core/composables/useAsyncOperation'
|
||||||
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
|
||||||
import type { PaymentService } from '@/core/services/PaymentService'
|
import type { PaymentService } from '@/core/services/PaymentService'
|
||||||
import type { TicketApiService } from '../services/TicketApiService'
|
import type { TicketApiService } from '../services/TicketApiService'
|
||||||
|
import { useOwnedTickets } from './useOwnedTickets'
|
||||||
|
|
||||||
export function useTicketPurchase() {
|
export function useTicketPurchase() {
|
||||||
const { isAuthenticated, currentUser } = useAuth()
|
const { isAuthenticated, currentUser } = useAuth()
|
||||||
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as PaymentService
|
const paymentService = injectService(SERVICE_TOKENS.PAYMENT_SERVICE) as PaymentService
|
||||||
const ticketApi = injectService(SERVICE_TOKENS.TICKET_API) as TicketApiService
|
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
|
// Async operations
|
||||||
const purchaseOperation = useAsyncOperation()
|
const purchaseOperation = useAsyncOperation()
|
||||||
|
|
||||||
|
|
@ -178,6 +185,12 @@ export function useTicketPurchase() {
|
||||||
clearInterval(checkInterval)
|
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
|
// Multi-ticket purchases come back with `ticketIds` (N rows
|
||||||
// sharing one invoice). Single-ticket purchases include
|
// sharing one invoice). Single-ticket purchases include
|
||||||
// `ticketId` only. Render one QR per row so each attendee
|
// `ticketId` only. Render one QR per row so each attendee
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue