Skip to content

fix(Deck): reset build ceiling when applying synced slide state#8

Open
chinesepowered wants to merge 1 commit into
stackblitz:mainfrom
chinesepowered:presenter-sync-curmax
Open

fix(Deck): reset build ceiling when applying synced slide state#8
chinesepowered wants to merge 1 commit into
stackblitz:mainfrom
chinesepowered:presenter-sync-curmax

Conversation

@chinesepowered

Copy link
Copy Markdown

What

The presenter/audience BroadcastChannel handler applies a remote slide and click count, but never updates curMax (the per-slide build ceiling):

c.onmessage = (e) => {
  if (e.data?.type === 'state') {
    applyingRemote.current = true;
    setSlide(e.data.slide);
    setClicks(e.data.clicks);
  }
};

Local navigation through go() always resets curMax to the incoming slide's registered maximum. The remote path skips that, and since registerMax only ever raises curMax, the synced tab carries the previous slide's ceiling forward.

The effect: after the presenter jumps between slides, hasNext / hasPrev and the prev/next arrows on the synced tab can be wrong — e.g. Next stays enabled at the true end of a slide that has fewer builds than the one before it.

Fix

Mirror go() in the remote handler: set curMax to max(registered max for the incoming slide, incoming clicks). The incoming clicks is included because the synced tab may not have visited that slide yet (so its registered max is still 0), but it must be able to show the builds the presenter has already revealed. Once the slide renders, registerMax tops it up to the true maximum if higher.

Changes

  • src/deck/Deck.tsx — set curMax alongside slide/clicks in the BroadcastChannel onmessage handler.

Verification

  • npx tsc --noEmit
  • npm run build

The BroadcastChannel handler applied a remote slide + click count but never updated curMax. Local navigation via go() resets curMax to the target slide's registered maximum; the remote path skipped that, and because registerMax only ever raises curMax, the synced/audience tab carried the previous slide's ceiling forward. After the presenter jumped between slides, hasNext/hasPrev and the prev/next arrows on the synced tab could be wrong (e.g. Next stayed enabled at the end of a slide with fewer builds). Mirror go() by setting curMax to max(registered max for the incoming slide, incoming clicks).
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