Skip to content

perf(clock): migrate Redux clock state to ClockProvider hooks#206

Open
gcutrini wants to merge 8 commits into
mainfrom
feature/clock-state-migration
Open

perf(clock): migrate Redux clock state to ClockProvider hooks#206
gcutrini wants to merge 8 commits into
mainfrom
feature/clock-state-migration

Conversation

@gcutrini

@gcutrini gcutrini commented May 28, 2026

Copy link
Copy Markdown
Contributor

ref: https://app.clickup.com/t/86b8e70g2

Summary

Replaces the Redux clock state machinery (per-second dispatch cascade through clock-reducer / clock-actions / ClockComponent) with uicore 4.2.31's ClockProvider + useSyncExternalStoreWithSelector hooks. Consumers re-render only when the value they actually use changes, not on every tick.

Bumps openstack-uicore-foundation from 4.2.30 to 4.2.31.

Commits

Commit Change
cb3ab34 summit_phase consumers → useSummitPhase (16 files; wraps app in ClockProvider, kills prop drilling for summitPhase)
b8a5f83 nowUtc consumers (Countdown, SpeakersWidget) → useClock
b6cc85d events_phases + event-page → useEventPhase(event); class component now compares the phase prop directly
faa2117 voting periods → useVotingPeriodPhase / useVotingPeriodsPhasesMap; deletes clock-actions.js, clock-reducer.js, ClockComponent.js, drops clockState from store, removes the phase field from the Redux voting-period mirror
9a7add2 adds useClockMinute and routes Countdown + SpeakersWidget through it (~60× fewer re-renders for minute-grained displays)
8c1bf9d event-page: inline eventPhase usage (drops the currentPhase alias) and remove a leftover debug console.log
a379436 extracts useVotingPeriodNotifications shared by posters-page + poster-detail-page (~80 LOC deduplicated)
67d65ef fixes the pre-existing firstHalf stale-until-phase-change bug in event-page (was never flipping at the event midpoint because shouldComponentUpdate only allowed phase-change re-renders)

gcutrini added 8 commits May 27, 2026 19:43
Wraps the app root in uicore's ClockProvider and adds useSummitPhase, a
selector hook that returns the current summit phase computed from the
shared clock context. All eight Redux-bound consumers of clockState.summit_phase
now call the hook directly, dropping the prop and the related mapStateToProps
entry. Receiver components (templates, routes, pages) that were just relaying
the value via prop drilling are now self-sufficient.
Countdown converts from class to function. SpeakersWidget drops the
clockState entry from mapStateToProps and reads nowUtc from the hook
inside the component.
Adds useEventPhase(event) selector hook backed by useClockSelector. The
EventPage container reads nowUtc and eventPhase from hooks and passes
them to the EventPageTemplate class, which now compares eventPhase
directly instead of looking up entries in clockState.events_phases.
Adds useVotingPeriodPhase / useVotingPeriodsPhasesMap, migrates poster
grid and detail pages off the Redux-mirrored voting-period phase, and
deletes the entire Redux clock plumbing (clock-actions, clock-reducer,
ClockComponent). Phase transition notifications now compare against a
useRef snapshot of the previous phases map.
…ularity

Adds useClockMinute, a clock selector that snaps nowUtc down to the
nearest minute. Countdown and SpeakersWidget consume it instead of
useClock, so they re-render at minute boundaries rather than every
tick. Both display minute-or-coarser precision, so behaviour is
preserved.
Removes the const currentPhase = eventPhase alias that was being kept
for compatibility with the pre-hook internal variable name, replacing
the internal currentPhase usages with the eventPhase prop directly.
Also removes the EventPageTemplate::render console.log left over from
the pre-hook era.
Posters page and poster detail page had nearly identical effects for
voting period notifications (initial load, BEFORE->DURING / DURING->AFTER
transitions, max-votes reached). Moves the logic into a shared hook and
hides the notifiedOnLoad and previous-phases-ref state inside it.
shouldComponentUpdate only allowed re-renders on phase change, so the
inline firstHalf calculation inside render was stuck on its initial
DURING value and never flipped at the midpoint. Computes firstHalf via
useClockSelector in the outer functional EventPage, passes it as a prop,
and adds it to the class sCU check so the midpoint transition triggers
a re-render. Drops the now-unused nowUtc prop from EventPageTemplate.
@netlify

netlify Bot commented May 28, 2026

Copy link
Copy Markdown

Deploy Preview for qa-fnvirtual failed. Why did it fail? →

Name Link
🔨 Latest commit 67d65ef
🔍 Latest deploy log https://app.netlify.com/projects/qa-fnvirtual/deploys/6a182332bf511c0008c48a4b

@gcutrini gcutrini requested a review from smarcet May 28, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant