Fix client not receiving timerEnabled state from host
The client's gameConfig always used DEFAULT_GAME_CONFIG (timerEnabled: true), so the GameScreen never showed the infinity symbol or End Question button. Now the client syncs timerEnabled from QUESTION_START and WELCOME messages into its local gameConfig state.
This commit is contained in:
parent
d1f82440a1
commit
b2f9f9a891
1 changed files with 6 additions and 0 deletions
|
|
@ -1507,6 +1507,9 @@ export const useGame = (defaultGameConfig?: GameConfig) => {
|
|||
setGameState('LOBBY');
|
||||
setHasAnswered(false);
|
||||
}
|
||||
if (payload.timerEnabled !== undefined) {
|
||||
setGameConfig(prev => ({ ...prev, timerEnabled: payload.timerEnabled! }));
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'START_COUNTDOWN') {
|
||||
|
|
@ -1546,6 +1549,9 @@ export const useGame = (defaultGameConfig?: GameConfig) => {
|
|||
if (data.payload.timerEnabled !== false) {
|
||||
timerRef.current = setInterval(() => setTimeLeft(prev => Math.max(0, prev - 100)), 100);
|
||||
}
|
||||
if (data.payload.timerEnabled !== undefined) {
|
||||
setGameConfig(prev => ({ ...prev, timerEnabled: data.payload.timerEnabled! }));
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'RESULT') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue