From 152d0541d4dd24aff767c51cb84fcf09229c29de Mon Sep 17 00:00:00 2001 From: Alexandre POMMIER Date: Mon, 26 Jun 2023 02:27:43 +0200 Subject: [PATCH] add useeffect app for return --- containers/api/src/app.controller.ts | 4 ++-- containers/api/src/chat/chat.service.ts | 2 +- containers/react/src/components/App.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/containers/api/src/app.controller.ts b/containers/api/src/app.controller.ts index 403506c0..b503c806 100644 --- a/containers/api/src/app.controller.ts +++ b/containers/api/src/app.controller.ts @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 01:00:00 by apommier #+# #+# */ -/* Updated: 2023/06/26 00:47:07 by apommier ### ########.fr */ +/* Updated: 2023/06/26 02:23:56 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -451,7 +451,7 @@ export class AppController { @UseGuards(JwtAuthGuard) @Post('/quit') async setOffline(@Request() req) { - + console.log("cc quit here"); const user = await this.userService.findOne(req.user.username); user.status = 0; diff --git a/containers/api/src/chat/chat.service.ts b/containers/api/src/chat/chat.service.ts index d69bad68..3825f32f 100644 --- a/containers/api/src/chat/chat.service.ts +++ b/containers/api/src/chat/chat.service.ts @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 01:00:25 by apommier #+# #+# */ -/* Updated: 2023/06/24 18:47:59 by apommier ### ########.fr */ +/* Updated: 2023/06/26 02:07:45 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/containers/react/src/components/App.tsx b/containers/react/src/components/App.tsx index a2d017a2..6c22aa80 100644 --- a/containers/react/src/components/App.tsx +++ b/containers/react/src/components/App.tsx @@ -19,20 +19,20 @@ import DoubleAuth from "../pages/2fa.tsx"; import Game from "../pages/Game.tsx"; import Social from "./Social/Social.tsx"; import Logout from "./Profile/Logout.tsx"; - +import api from "../script/axiosApi.tsx" function AnimatedRoute () { // const location = useLocation(); useEffect(() => { - const handleBeforeUnload = (event: { preventDefault: () => void; returnValue: string; }) => { + const handleBeforeUnload = async (event: { preventDefault: () => void; returnValue: string; }) => { event.preventDefault(); // Cancel the default event behavior if needed event.returnValue = ''; // Chrome requires a return value to display a custom message if (!localStorage.getItem('token')) return ; try { - + await api.post("/quit"); } catch(err) { console.log(err); }