add > for gamesession and sessionnbr

This commit is contained in:
Alexandre POMMIER 2023-06-28 17:04:50 +02:00
parent 44183cd1b5
commit 86ceafae40
5 changed files with 16 additions and 15 deletions

View File

@ -6,7 +6,7 @@
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */ /* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/17 01:00:00 by apommier #+# #+# */ /* Created: 2023/06/17 01:00:00 by apommier #+# #+# */
/* Updated: 2023/06/28 13:57:06 by apommier ### ########.fr */ /* Updated: 2023/06/28 16:50:11 by apommier ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -54,9 +54,7 @@ export class AppController {
if(!user) if(!user)
return ; return ;
if (user.sessionNumber === 1) if (user.sessionNumber === 1)
{
user.status = 0; user.status = 0;
}
user.sessionNumber--; user.sessionNumber--;
this.userService.save(user); this.userService.save(user);
} }
@ -210,7 +208,8 @@ export class AppController {
@Post('/rmGame') @Post('/rmGame')
async removeGame(@Request() req, @Body() data: any) { async removeGame(@Request() req, @Body() data: any) {
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
user.gameSession -= 1; if (user.gameSession > 0)
user.gameSession -= 1;
if (user.gameSession === 0) if (user.gameSession === 0)
user.status = 1; user.status = 1;
await this.userService.save(user); await this.userService.save(user);
@ -303,7 +302,8 @@ export class AppController {
const user = await this.userService.findOne(req.user.username); const user = await this.userService.findOne(req.user.username);
if (!user) if (!user)
return ; return ;
user.sessionNumber--; if (user.sessionNumber > 0)
user.sessionNumber--;
console.log("seesion number=", user.sessionNumber) console.log("seesion number=", user.sessionNumber)
if (!user.sessionNumber) if (!user.sessionNumber)
user.status = 0; user.status = 0;

View File

@ -1,6 +1,6 @@
REACT_APP_BASE_URL=paul-f4Ar4s3:8080 REACT_APP_BASE_URL=paul-f5Ar4s4:8080
REACT_APP_SOCKET_URL=paul-f4Ar4s3 REACT_APP_SOCKET_URL=paul-f5Ar4s4
REACT_APP_API_SECRET=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 REACT_APP_API_SECRET=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
REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789 REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789
@ -8,7 +8,7 @@ REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d
# REACT_APP_BASE_URL=92.143.191.152 # REACT_APP_BASE_URL=92.143.191.152
# REACT_APP_BASE_URL=192.168.1.19 # REACT_APP_BASE_URL=192.168.1.19
REACT_APP_INTRA_URL="https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789&redirect_uri=http%3A%2F%2Fpaul-f4Ar4s3%3A8080%2Fapi%2Fauth%2Flogin&response_type=code" REACT_APP_INTRA_URL="https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789&redirect_uri=http%3A%2F%2Fpaul-f5Ar4s4%3A8080%2Fapi%2Fauth%2Flogin&response_type=code"
# REACT_APP_BASE_URL=92.143.191.152 # REACT_APP_BASE_URL=92.143.191.152
# REACT_APP_BASE_URL=192.168.1.19 # REACT_APP_BASE_URL=192.168.1.19

View File

@ -48,11 +48,13 @@ function AnimatedRoute() {
handleLoad(); handleLoad();
window.addEventListener("beforeunload", async (event) => { window.addEventListener("beforeunload", async (event) => {
if (!localStorage.getItem('token'))
return;
await api.post("/quit"); await api.post("/quit");
}); });
window.addEventListener("unload", async (event) => { // window.addEventListener("unload", async (event) => {
await api.post("/quit"); // await api.post("/quit");
}); // });
return () => { return () => {

View File

@ -86,8 +86,7 @@ const Modal = ({handleClose}: ModalProps) => {
const ret = await api.post("/verifyPassword", {convId: channel, password: PassWord}) const ret = await api.post("/verifyPassword", {convId: channel, password: PassWord})
if (ret) if (ret)
console.log("ici ret password", ret); console.log("ici ret password", ret);
// window.location.reload();
// window.location.reload();
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
@ -115,7 +114,7 @@ const Modal = ({handleClose}: ModalProps) => {
console.log("ici test channel= ", channel) console.log("ici test channel= ", channel)
await api.post("/join", {convId: channel}) await api.post("/join", {convId: channel})
window.location.reload(); // window.location.reload();
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }

View File

@ -63,7 +63,7 @@ services:
- 5432:5432 - 5432:5432
volumes: volumes:
- db:/var/lib/postgresql/data - db:/var/lib/postgresql/data
- ./conf/init.sql:/docker-entrypoint-initdb.d/create_tables.sql # - ./conf/init.sql:/docker-entrypoint-initdb.d/create_tables.sql
networks: networks:
- pongNetwork - pongNetwork