fix(events): let the organizer's own record win when merging My Events
The authenticated fetch returns the full Event (incl. extra.promo_codes, which public responses omit as of events ext v1.6.1-aio.12) and is what the edit dialog must prefill from. Public records still win for events the user does not own. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByAwHU4pRnyE58YocQvAas
This commit is contained in:
parent
a68fed916d
commit
262e674f9f
1 changed files with 9 additions and 6 deletions
|
|
@ -13,9 +13,10 @@ export function useMyEvents() {
|
||||||
// and merge them into the feed. Otherwise an event that drops to
|
// and merge them into the feed. Otherwise an event that drops to
|
||||||
// `proposed` after a non-admin edit disappears from the user's view
|
// `proposed` after a non-admin edit disappears from the user's view
|
||||||
// entirely — they'd be unable to find it to make a follow-up edit or
|
// entirely — they'd be unable to find it to make a follow-up edit or
|
||||||
// monitor its approval status. Public approved events from other
|
// monitor its approval status. For the user's OWN events the
|
||||||
// users take precedence on dedup (server is the source of truth for
|
// authenticated record wins on dedup: it is the full `Event` (incl.
|
||||||
// the public view).
|
// `extra.promo_codes`, which public responses omit), and it is what
|
||||||
|
// the edit dialog must prefill from.
|
||||||
const fetchAll = async (): Promise<TicketedEvent[]> => {
|
const fetchAll = async (): Promise<TicketedEvent[]> => {
|
||||||
const publicEvents = (await ticketApi.fetchTicketedEvents()) as TicketedEvent[]
|
const publicEvents = (await ticketApi.fetchTicketedEvents()) as TicketedEvent[]
|
||||||
|
|
||||||
|
|
@ -26,9 +27,11 @@ export function useMyEvents() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const myEvents = (await ticketApi.fetchMyEvents(invoiceKey)) as TicketedEvent[]
|
const myEvents = (await ticketApi.fetchMyEvents(invoiceKey)) as TicketedEvent[]
|
||||||
const seen = new Set(publicEvents.map((e) => e.id))
|
const own = new Map(myEvents.map((e) => [e.id, e]))
|
||||||
const own = myEvents.filter((e) => !seen.has(e.id))
|
const merged = publicEvents.map((e) => own.get(e.id) ?? e)
|
||||||
return [...publicEvents, ...own]
|
const publicIds = new Set(publicEvents.map((e) => e.id))
|
||||||
|
const ownOnly = myEvents.filter((e) => !publicIds.has(e.id))
|
||||||
|
return [...merged, ...ownOnly]
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Falling back to just the public feed is acceptable — the user
|
// Falling back to just the public feed is acceptable — the user
|
||||||
// can still browse, they just won't see their own pending events.
|
// can still browse, they just won't see their own pending events.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue