mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-14 04:25:35 +01:00
feat(game): enhance game reconnection logic and improve reset messages
This commit is contained in:
@@ -49,10 +49,11 @@ const Game = () => {
|
||||
reset()
|
||||
})
|
||||
|
||||
useEvent("game:reset", () => {
|
||||
useEvent("game:reset", (message) => {
|
||||
router.replace("/")
|
||||
reset()
|
||||
toast("The game has been reset by the host")
|
||||
setQuestionStates(null)
|
||||
toast.error(message)
|
||||
})
|
||||
|
||||
if (!gameIdParam) {
|
||||
@@ -61,7 +62,7 @@ const Game = () => {
|
||||
|
||||
let component = null
|
||||
|
||||
switch (status.name) {
|
||||
switch (status?.name) {
|
||||
case STATUS.WAIT:
|
||||
component = <Wait data={status.data} />
|
||||
|
||||
@@ -93,7 +94,7 @@ const Game = () => {
|
||||
break
|
||||
}
|
||||
|
||||
return <GameWrapper statusName={status.name}>{component}</GameWrapper>
|
||||
return <GameWrapper statusName={status?.name}>{component}</GameWrapper>
|
||||
}
|
||||
|
||||
export default Game
|
||||
|
||||
@@ -47,10 +47,11 @@ const ManagerGame = () => {
|
||||
},
|
||||
)
|
||||
|
||||
useEvent("game:reset", () => {
|
||||
useEvent("game:reset", (message) => {
|
||||
router.replace("/manager")
|
||||
reset()
|
||||
toast("Game is not available anymore")
|
||||
setQuestionStates(null)
|
||||
toast.error(message)
|
||||
})
|
||||
|
||||
const handleSkip = () => {
|
||||
@@ -58,7 +59,7 @@ const ManagerGame = () => {
|
||||
return
|
||||
}
|
||||
|
||||
switch (status.name) {
|
||||
switch (status?.name) {
|
||||
case STATUS.SHOW_ROOM:
|
||||
socket?.emit("manager:startGame", { gameId })
|
||||
|
||||
@@ -83,7 +84,7 @@ const ManagerGame = () => {
|
||||
|
||||
let component = null
|
||||
|
||||
switch (status.name) {
|
||||
switch (status?.name) {
|
||||
case STATUS.SHOW_ROOM:
|
||||
component = <Room data={status.data} />
|
||||
|
||||
@@ -126,7 +127,7 @@ const ManagerGame = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<GameWrapper statusName={status.name} onNext={handleSkip} manager>
|
||||
<GameWrapper statusName={status?.name} onNext={handleSkip} manager>
|
||||
{component}
|
||||
</GameWrapper>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user