Skip to content

perf(list): resolve each class card's display once, not twice #505

Description

@Ardnived

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

  • EventFacts and EventChips take the EventDisplayStrings their parent already holds, through a prop, instead of calling useEventDisplay themselves. Each reads only its own surface's view: surfaces[surface], plus the where strings for EventFacts.
  • The parents call the hook once each:
    • EventListItem, at src/components/molecules/EventListItem/EventListItem.tsx:130,142;
    • EventDetails, at src/components/organisms/EventDetails/EventDetails.tsx;
    • RegistrationView and ShareView, for the summary facts.
  • EventListItem stays 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 resolveEventDisplay once.
  • 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 EventListItem for one event with resolveEventDisplay spied, and asserts one call. Watch it fail on main, which makes two.
  • pnpm lint && pnpm typecheck && pnpm test:run pass, including the existing EventFacts, EventChips and "Today once" specs, unchanged in what they assert.
  • pnpm ladle, Views › Search: the cards look identical to main.

Notes

Activity

  1. added theissue type on Nov 26, 2026
  2. added a commit that references this issue on Nov 26, 2026
    ec4af1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions