diff --git a/src/main/client/src/feature/lobby/Lobby.jsx b/src/main/client/src/feature/lobby/Lobby.jsx index 7453c8b..8d4b2b6 100644 --- a/src/main/client/src/feature/lobby/Lobby.jsx +++ b/src/main/client/src/feature/lobby/Lobby.jsx @@ -73,7 +73,7 @@ export function Lobby() { initialized.current = true let sub = stompClient.subscribe("/topic/gamestart", (message) => { let r = JSON.parse(message.body) - if (r.opponent === auth.name) { + if (r.players.includes(auth.name)) { navigate(base + "/game/" + r.id) } }) diff --git a/src/main/client/src/feature/lobby/Requests.jsx b/src/main/client/src/feature/lobby/Requests.jsx index e7aeea9..560c36c 100644 --- a/src/main/client/src/feature/lobby/Requests.jsx +++ b/src/main/client/src/feature/lobby/Requests.jsx @@ -8,10 +8,6 @@ import { twJoin, } from "tailwind-merge" import { - useNavigate, -} from "react-router-dom" -import { - base, StompContext, tfetch, doTry, @@ -24,7 +20,6 @@ export function Requests({lobbyState}) { let [requests, setRequests] = useState([]) let openGameId = lobbyState.openGameId let stompClient = useContext(StompContext) - let navigate = useNavigate() let auth = useAuthStore(state => state.auth) let initialized = useRef() useEffect(() => { @@ -47,7 +42,7 @@ export function Requests({lobbyState}) { return () => { sub1.unsubscribe() } - }, [auth, initialized, stompClient, navigate, openGameId]) + }, [auth, initialized, stompClient, openGameId]) if (!openGameId) { return
} @@ -65,7 +60,6 @@ export function Requests({lobbyState}) { } function Request({request}) { - let navigate = useNavigate() let auth = useAuthStore(state => state.auth) return (
start(@RequestBody AcceptRequest acceptRequest) { chat.messages().add(startMessage); operations.convertAndSend("/topic/chat/" + chat.id(), startMessage); operations.convertAndSend("/topic/gamestart", Map.of( - "opponent", acceptRequest.opponent(), + "players", List.of(principal, acceptRequest.opponent()), "id", openGame.id())); operations.convertAndSend("/topic/lobby/open_games", openGames.games()); operations.convertAndSend("/topic/lobby/active_games", activeGames.games());