perf(clock): migrate Redux clock state to ClockProvider hooks#206
Open
gcutrini wants to merge 8 commits into
Open
perf(clock): migrate Redux clock state to ClockProvider hooks#206gcutrini wants to merge 8 commits into
gcutrini wants to merge 8 commits into
Conversation
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.
❌ Deploy Preview for qa-fnvirtual failed. Why did it fail? →
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sClockProvider+useSyncExternalStoreWithSelectorhooks. Consumers re-render only when the value they actually use changes, not on every tick.Bumps
openstack-uicore-foundationfrom4.2.30to4.2.31.Commits
useSummitPhase(16 files; wraps app inClockProvider, kills prop drilling forsummitPhase)useClockuseEventPhase(event); class component now compares the phase prop directlyuseVotingPeriodPhase/useVotingPeriodsPhasesMap; deletesclock-actions.js,clock-reducer.js,ClockComponent.js, dropsclockStatefrom store, removes thephasefield from the Redux voting-period mirroruseClockMinuteand routes Countdown + SpeakersWidget through it (~60× fewer re-renders for minute-grained displays)eventPhaseusage (drops thecurrentPhasealias) and remove a leftover debugconsole.loguseVotingPeriodNotificationsshared by posters-page + poster-detail-page (~80 LOC deduplicated)firstHalfstale-until-phase-change bug inevent-page(was never flipping at the event midpoint becauseshouldComponentUpdateonly allowed phase-change re-renders)