Skip to content

Eliminate discard flicker by deriving play state directly from fetcher data#158

Merged
tknkaa merged 4 commits intomainfrom
copilot/fix-discard-visual-glitch
Apr 24, 2026
Merged

Eliminate discard flicker by deriving play state directly from fetcher data#158
tknkaa merged 4 commits intomainfrom
copilot/fix-discard-visual-glitch

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

After a discard, optimistic UI disappeared when discardFetcher.state returned to idle, but the useEffect sync into local gameState had not yet committed, causing a brief render of stale state. This change removes that async gap by making render state synchronous and derived.

  • State source of truth

    • Removed local gameState (useState) and both sync effects (useEffect) from app/routes/play.tsx.
    • Replaced with a single derived state for rendering:
      const currentGameState = discardFetcher.data ?? loaderData;
      const { sutehai, tsumohai, nextTsumohai, junme, kyoku, tehai, remainTsumo, score } = currentGameState;
  • Reference migration

    • Replaced component references from gameState to currentGameState where base state is read.
    • Kept optimistic discard/tsumogiri calculation logic unchanged.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
hitori-mahjong 971ed61 Apr 24 2026, 05:51 AM

@tknkaa tknkaa marked this pull request as ready for review April 24, 2026 06:00
@tknkaa tknkaa merged commit 7300956 into main Apr 24, 2026
1 of 2 checks passed
@tknkaa tknkaa deleted the copilot/fix-discard-visual-glitch branch April 24, 2026 06:00
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.

2 participants