diff --git a/frontend/src/chat/chat.ts b/frontend/src/chat/chat.ts index e793426..4c5f1fc 100644 --- a/frontend/src/chat/chat.ts +++ b/frontend/src/chat/chat.ts @@ -9,6 +9,7 @@ import type { import type { User } from "@app/auth"; import { addRoute, + navigateTo, setTitle, type RouteHandlerParams, type RouteHandlerReturn, @@ -312,14 +313,14 @@ sendButton?.addEventListener("click", () => { case "@pong": if (msgCommand[1] === "") { - window.location.href = "/app/pong/games"; + navigateTo("/app/pong/games"); quitChat(); } break; case "@ttt": if (msgCommand[1] === "") { - window.location.href = "/app/ttt/games"; + navigateTo("/app/ttt/games"); quitChat(); } break; @@ -432,12 +433,12 @@ bquit?.addEventListener("click", () => { }); myGames?.addEventListener("click", () => { - window.location.href = "/app/pong/games"; + navigateTo("/app/pong/games"); quitChat(); }); myTTTGames?.addEventListener("click", () => { - window.location.href = "/app/ttt/games"; + navigateTo("/app/ttt/games"); quitChat(); }); diff --git a/frontend/src/chat/chatHelperFunctions/actionBtnPongGames.ts b/frontend/src/chat/chatHelperFunctions/actionBtnPongGames.ts index d90d2db..399a11b 100644 --- a/frontend/src/chat/chatHelperFunctions/actionBtnPongGames.ts +++ b/frontend/src/chat/chatHelperFunctions/actionBtnPongGames.ts @@ -1,5 +1,7 @@ +import { navigateTo } from "@app/routing"; import type { ClientProfil } from "../types_front"; import { Socket } from "socket.io-client"; +import { quitChat } from "./quitChat"; /** * function listens for a click on the Pong Games history button @@ -11,7 +13,8 @@ export function actionBtnPongGames(profile: ClientProfil, senderSocket: Socket) setTimeout(() => { const userGames = document.querySelector("#popup-b-hGame"); userGames?.addEventListener("click", () => { - window.location.href = `/app/pong/games/${profile.userID}`; + navigateTo(`/app/pong/games/${profile.userID}`); + quitChat(); }); }, 0) }; \ No newline at end of file diff --git a/frontend/src/chat/chatHelperFunctions/actionBtnTTTGames.ts b/frontend/src/chat/chatHelperFunctions/actionBtnTTTGames.ts index 78aa5d9..bc2a7d2 100644 --- a/frontend/src/chat/chatHelperFunctions/actionBtnTTTGames.ts +++ b/frontend/src/chat/chatHelperFunctions/actionBtnTTTGames.ts @@ -1,5 +1,7 @@ +import { navigateTo } from "@app/routing"; import type { ClientProfil } from "../types_front"; import { Socket } from "socket.io-client"; +import { quitChat } from "./quitChat"; /** * function listens for a click on the TTT game History button @@ -11,7 +13,8 @@ export function actionBtnTTTGames(profile: ClientProfil, senderSocket: Socket) { setTimeout(() => { const userGames = document.querySelector("#popup-b-hTGame"); userGames?.addEventListener("click", () => { - window.location.href = `/app/ttt/games/${profile.userID}`; + navigateTo(`/app/ttt/games/${profile.userID}`); + quitChat(); }); }, 0) }; \ No newline at end of file