Skip to content

Commit

Permalink
hacer que el historial se guarde una unica vez
Browse files Browse the repository at this point in the history
  • Loading branch information
bidof committed May 1, 2024
1 parent de46dfe commit 3b9ac59
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions webapp/src/components/game/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,20 @@ function Game({darkMode,gameMode=new BasicGame()}) {
} else if (gameModeRef.current.questions.length>0){//comprobar que no sea vacia para que le ljuego no finalize al empezar
console.log("use effect finish");
setIsFinished(true);
//poner el tiepo que tardo
console.log("tiempo total tardado en acabar ",totalTime);
gameModeRef.current.setTiempoTotal(totalTime);
gameModeRef.current.finishGame();
gameModeRef.current.sendHistory({correctas: correctAnswers, incorrectas: incorrectAnswers, tiempoTotal: totalTime});
}

}


}, [correctAnswers, incorrectAnswers,totalTime, isFinished]);//<-cambiar el array de depencias error despliegue

//para aseguarte que el historial se envie una vez lo separas
useEffect(() => {
if (isFinished) {
console.log("tiempo total tardado en acabar ", totalTime);
gameModeRef.current.setTiempoTotal(totalTime);
gameModeRef.current.finishGame();
gameModeRef.current.sendHistory({correctas: correctAnswers, incorrectas: incorrectAnswers, tiempoTotal: totalTime});
}
}, [isFinished]);
const handleTimeout = () => {
handleAnswerSelect(false);
};
Expand Down

0 comments on commit 3b9ac59

Please sign in to comment.