Repository navigation
Description
Summary
Every class card in a list works out its display state twice. EventFacts and EventChips each call useEventDisplay(event), and each call keeps its own useMemo. So the resolver, the luxon date formatting and an Intl.ListFormat all run twice per card. A results list reveals up to 400 rows (MAX_REVEAL), which means up to about 800 resolver runs where 400 would do. src/lib/shape/reveal.ts:90 already names the per-card render as the real lever on the list's felt cost. Nothing visible changes.
Approach
EventFactsandEventChipstake theEventDisplayStringstheir parent already holds, through a prop, instead of callinguseEventDisplaythemselves. Each reads only its own surface's view:surfaces[surface], plus the where strings for EventFacts.- The parents call the hook once each:
EventListItem, atsrc/components/molecules/EventListItem/EventListItem.tsx:130,142;EventDetails, atsrc/components/organisms/EventDetails/EventDetails.tsx;RegistrationViewandShareView, for the summary facts.
EventListItemstays memoized, so the one hook call sits inside the memo.- The map pin popover (
Map.tsx:183) calls the hook once already, and is unchanged. - Keep one way to supply the strings, with no optional fallback that re-runs the hook (the "prefer simple over compat" rule).
Acceptance criteria
- Rendering one list card runs
resolveEventDisplayonce. - Rendering the class page body runs it once for the chips and the facts together.
- Every surface renders exactly the same markup as before: chips, facts, "Today", inactive listings.
Verification checklist
- A unit spec renders
EventListItemfor one event withresolveEventDisplayspied, and asserts one call. Watch it fail onmain, which makes two. -
pnpm lint && pnpm typecheck && pnpm test:runpass, including the existingEventFacts,EventChipsand "Today once" specs, unchanged in what they assert. -
pnpm ladle, Views › Search: the cards look identical tomain.
Notes
- Found by the review of fix(event): one meaning of "inactive", "Today" once, and no Full chip #500. fix(event): one meaning of "inactive", "Today" once, and no Full chip #500's
surfaceViewmade this a small change: both components already read one view object from the hook. - Optional evidence for the PR: time the Search story's 400-row reveal before and after, in a browser profile.
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
Low
Hold Until
None yet
Projects
- StatusShow more project fieldsDone
Activity
perf(event): resolve each event's display once per surface (#508)