fix: always show game control buttons in room-based sessions
In room-based multiplayer games, force canModifyPlayers=false to ensure Setup, New Game, and Quit buttons are always visible to all room members. The arcade session locking mechanism (hasActiveSession) doesn't apply to room-based games, so we detect rooms via isInRoom and override the canModifyPlayers logic. This fixes the issue where some room members saw buttons while others didn't, depending on their arcade session state. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { useRouter } from 'next/navigation'
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { PageWithNav } from '@/components/PageWithNav'
|
||||
import { useArcadeRedirect } from '@/hooks/useArcadeRedirect'
|
||||
import { useRoomData } from '@/hooks/useRoomData'
|
||||
import { css } from '../../../../../styled-system/css'
|
||||
import { StandardGameLayout } from '../../../../components/StandardGameLayout'
|
||||
import { useFullscreen } from '../../../../contexts/FullscreenContext'
|
||||
@@ -14,9 +15,13 @@ import { SetupPhase } from './SetupPhase'
|
||||
|
||||
export function MemoryPairsGame() {
|
||||
const router = useRouter()
|
||||
const { state, exitSession, resetGame } = useMemoryPairs()
|
||||
const { state, exitSession, resetGame, goToSetup } = useMemoryPairs()
|
||||
const { setFullscreenElement } = useFullscreen()
|
||||
const { canModifyPlayers } = useArcadeRedirect({ currentGame: 'matching' })
|
||||
const { isInRoom } = useRoomData()
|
||||
const arcadeRedirect = useArcadeRedirect({ currentGame: 'matching' })
|
||||
// In rooms, always show buttons (canModifyPlayers = false shows buttons)
|
||||
// In arcade sessions, use normal arcade redirect logic
|
||||
const canModifyPlayers = isInRoom ? false : arcadeRedirect.canModifyPlayers
|
||||
const gameRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -37,11 +42,14 @@ export function MemoryPairsGame() {
|
||||
exitSession()
|
||||
router.push('/arcade')
|
||||
}}
|
||||
onSetup={() => {
|
||||
// Exit current session and return to arcade (which will redirect to setup)
|
||||
exitSession()
|
||||
router.push('/arcade/matching')
|
||||
}}
|
||||
onSetup={
|
||||
goToSetup
|
||||
? () => {
|
||||
// Transition to setup phase (will pause game if active)
|
||||
goToSetup()
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
onNewGame={() => {
|
||||
resetGame()
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user