diff --git a/packages/socket/src/services/game.ts b/packages/socket/src/services/game.ts index 61352f6..871e2be 100644 --- a/packages/socket/src/services/game.ts +++ b/packages/socket/src/services/game.ts @@ -203,7 +203,7 @@ class Game { socket.emit("manager:successReconnect", { gameId: this.gameId, currentQuestion: { - current: this.round.currentQuestion, + current: this.round.currentQuestion + 1, total: this.quizz.questions.length, }, status, @@ -250,7 +250,7 @@ class Game { socket.emit("player:successReconnect", { gameId: this.gameId, currentQuestion: { - current: this.round.currentQuestion, + current: this.round.currentQuestion + 1, total: this.quizz.questions.length, }, status, diff --git a/packages/web/src/components/game/GameWrapper.tsx b/packages/web/src/components/game/GameWrapper.tsx index 8ff12c2..b6864b0 100644 --- a/packages/web/src/components/game/GameWrapper.tsx +++ b/packages/web/src/components/game/GameWrapper.tsx @@ -8,8 +8,9 @@ import { useEvent, useSocket } from "@rahoot/web/contexts/socketProvider" import { usePlayerStore } from "@rahoot/web/stores/player" import { useQuestionStore } from "@rahoot/web/stores/question" import { MANAGER_SKIP_BTN } from "@rahoot/web/utils/constants" +import clsx from "clsx" import Image from "next/image" -import { PropsWithChildren } from "react" +import { PropsWithChildren, useEffect, useState } from "react" type Props = PropsWithChildren & { statusName: Status | undefined @@ -21,6 +22,7 @@ const GameWrapper = ({ children, statusName, onNext, manager }: Props) => { const { isConnected } = useSocket() const { player } = usePlayerStore() const { questionStates, setQuestionStates } = useQuestionStore() + const [isDisabled, setIsDisabled] = useState(false) const next = statusName ? MANAGER_SKIP_BTN[statusName] : null useEvent("game:updateQuestion", ({ current, total }) => { @@ -30,6 +32,15 @@ const GameWrapper = ({ children, statusName, onNext, manager }: Props) => { }) }) + useEffect(() => { + setIsDisabled(false) + }, [statusName]) + + const handleNext = () => { + setIsDisabled(true) + onNext?.() + } + return (
@@ -56,8 +67,10 @@ const GameWrapper = ({ children, statusName, onNext, manager }: Props) => { {manager && next && (