diff --git a/sites/events/index.html b/sites/events/index.html index 41f04ca..fbdcc7e 100644 --- a/sites/events/index.html +++ b/sites/events/index.html @@ -37,8 +37,8 @@ - -
+ + diff --git a/sites/events/src/main.js b/sites/events/src/main.js index c1f6e88..cc03d97 100644 --- a/sites/events/src/main.js +++ b/sites/events/src/main.js @@ -240,12 +240,17 @@ function setupFilters() { btn.classList.toggle("opacity-40", !nowActive); if (nowActive) set.add(btn.dataset.filterValue); else set.delete(btn.dataset.filterValue); - renderCircuits(); + renderEvents(); }); }); } -function eventCard(ev) { +// A single event can belong to more than one watched circuit (BCP events +// carry their own list of leagues, and it's common for e.g. a national +// league and a regional circuit to both include the same event) — badge +// it with every circuit it matched under rather than showing it once +// per circuit. +function eventCard(ev, circuits) { const capacity = ev.numTickets ? `${ev.checkedInPlayers ?? 0}/${ev.numTickets} checked in` : ""; @@ -255,6 +260,7 @@ function eventCard(ev) { const format = `${formatOf(ev)}`; const scope = scopeOf(ev); const scopeBadge = scope ? `${scope}` : ""; + const circuitBadges = circuits.map(c => `${esc(c.name)}`).join(""); return ` @@ -262,7 +268,7 @@ function eventCard(ev) {No upcoming events for this circuit.
`; - } else if (!filtered.length) { - body = `No events match the current filter.
`; - } else { - body = filtered.map(eventCard).join(""); +// Dedupe by event id across all circuits, collecting every circuit an +// event matched under, then sort the merged list chronologically — +// replaces the old one-section-per-circuit layout with a single feed. +function mergeEvents(results) { + const byId = new Map(); + for (const { circuit, events, error } of results) { + if (error) continue; + for (const ev of events) { + if (!byId.has(ev.id)) byId.set(ev.id, { event: ev, circuits: [] }); + byId.get(ev.id).circuits.push(circuit); + } } - return ` -Couldn't load events for this circuit — try refreshing.
Couldn't load: ${failed.map(esc).join(", ")} — try refreshing.
` + : ""; + + let body; + if (!merged.length) { + body = `No upcoming events found.
`; + } else if (!filtered.length) { + body = `No events match the current filter.
`; + } else { + body = `