Skip to content

Commit

Permalink
Merge pull request #453 from Arquisoft/laura
Browse files Browse the repository at this point in the history
Correccion bug almacenar record
  • Loading branch information
uo287627 authored May 2, 2024
2 parents bd9f965 + f327a3f commit eb9897f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions webapp/src/components/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => {

// Después de 3 segundos, restablecer la selección y pasar a la siguiente pregunta
setTimeout(async() => {
setNumberClics(numberClics + 1);
await obtenerPreguntaAleatoria();
setSelectedOption(null);
await addGeneratedQuestionBody();
setNumberClics(numberClics + 1);
setSelectedAnswer('');
}, delayBeforeNextQuestion);
}
Expand Down Expand Up @@ -177,14 +177,14 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => {
}
};

if ((timer >= timeLimit || numberClics === totalQuestions)&& !almacenado) {
if ((timer >= timeLimit || finished)&& !almacenado) {
(async () => {
await addRecord();
await updateRanking();
})();
setAlmacenado(true);
}
}, [timer, numberClics, totalQuestions, timeLimit, almacenado, apiEndpoint, correctQuestions, username, setError, themes, setThemesSelected]);
}, [timer, numberClics, totalQuestions, timeLimit, almacenado, apiEndpoint, correctQuestions, username, setError, themes, setThemesSelected, numberClics]);

if(isNaN(totalQuestions)){
totalQuestions=10;
Expand All @@ -195,7 +195,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => {

return (
<Container maxWidth="lg">
{numberClics >= totalQuestions || timer >= timeLimit ? (
{(numberClics >= totalQuestions || timer >= timeLimit) && almacenado? (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<Typography sx={{ mt: 4, mb: 2 }} variant="h6" component="div">
¡Gracias por jugar!
Expand Down

0 comments on commit eb9897f

Please sign in to comment.