File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,8 +337,10 @@ export const useBroadcastController = (): BroadcastStreamController => {
337337 const existingGameState = gameStates . current . get ( game . id )
338338 const newLiveGame = createLiveGameFromBroadcastGame ( game )
339339
340- // Play sound for new moves if game was already loaded
340+ // Play sound for new moves only if this is the currently selected game
341341 if (
342+ currentGame &&
343+ game . id === currentGame . id &&
342344 existingGameState &&
343345 newLiveGame . moves . length > existingGameState . moves . length
344346 ) {
@@ -362,16 +364,17 @@ export const useBroadcastController = (): BroadcastStreamController => {
362364 return newRoundData
363365 } )
364366
365- // Update current game if it exists in the new data
367+ // Update current game data if it's in the update, but don't switch to a different game
366368 if ( currentGame ) {
367- const updatedGame = parseResult . games . find (
369+ const updatedCurrentGame = parseResult . games . find (
368370 ( g ) => g . id === currentGame . id ,
369371 )
370- if ( updatedGame ) {
371- setCurrentGame ( updatedGame )
372+ if ( updatedCurrentGame ) {
373+ // Update the currently selected game with new data (including clocks)
374+ setCurrentGame ( updatedCurrentGame )
372375 }
373376 } else if ( parseResult . games . length > 0 ) {
374- // Auto-select first game if none selected
377+ // Auto-select first game only if no game is currently selected
375378 setCurrentGame ( parseResult . games [ 0 ] )
376379 }
377380
You can’t perform that action at this time.
0 commit comments