From 927bb1ff6ba43a42f283f0350a472c9229e69257 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 15 Dec 2023 10:41:47 +0100
Subject: [PATCH 1/3] fix bug sonar 1
---
cryptide_project/src/Pages/Lobbies.tsx | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/cryptide_project/src/Pages/Lobbies.tsx b/cryptide_project/src/Pages/Lobbies.tsx
index 02a6195..116efa0 100644
--- a/cryptide_project/src/Pages/Lobbies.tsx
+++ b/cryptide_project/src/Pages/Lobbies.tsx
@@ -28,7 +28,7 @@ class LobbyDataProps {
}
}
-let cptNavigation = 0
+// let cptNavigation = 0
function Lobbies() {
const theme=useTheme();
@@ -42,6 +42,8 @@ function Lobbies() {
const [showAvailable, setShowAvailable] = useState(true);
+ const [cptNavigation, setCptNavigation] = useState(0);
+
const handleShowAllClick = () => {
setShowAvailable(false);
};
@@ -67,7 +69,7 @@ function Lobbies() {
}
const navigationType = useNavigationType()
- cptNavigation++
+ setCptNavigation((prevCpt) => prevCpt + 1);
if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){
socket.emit("player quit")
From 5d89f8e1bd0d7dcaf18047663a0c83ca8b3f308f Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 15 Dec 2023 10:49:08 +0100
Subject: [PATCH 2/3] :ambulance:
---
cryptide_project/src/Pages/Lobbies.tsx | 27 ++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/cryptide_project/src/Pages/Lobbies.tsx b/cryptide_project/src/Pages/Lobbies.tsx
index 116efa0..8565b88 100644
--- a/cryptide_project/src/Pages/Lobbies.tsx
+++ b/cryptide_project/src/Pages/Lobbies.tsx
@@ -52,7 +52,19 @@ function Lobbies() {
setShowAvailable(true);
};
+ const handleSetFirst = () => {
+ setFirst(false);
+ socket.emit("request lobbies");
+ };
+
+ const handleSetCptNavigation = () => {
+ setCptNavigation((prevCpt) => prevCpt + 1);
+ const navigationType = useNavigationType();
+ if (cptNavigation % 2 === 0 && navigationType.toString() === "POP") {
+ socket.emit("player quit");
+ }
+ };
const filteredLobbies = lobbyData.filter((lobby) =>
lobby.roomNum.toLowerCase().includes(searchTerm.toLowerCase()) ||
lobby.headPlayer.pseudo.toLowerCase().includes(searchTerm.toLowerCase())
@@ -69,18 +81,17 @@ function Lobbies() {
}
const navigationType = useNavigationType()
- setCptNavigation((prevCpt) => prevCpt + 1);
- if (cptNavigation % 2 == 0){
- if (navigationType.toString() == "POP"){
- socket.emit("player quit")
- }
- }
+
+
+
+ handleSetCptNavigation();
if (first){
- setFirst(false)
- socket.emit("request lobbies")
+ handleSetFirst();
}
+
+
useEffect(() => {
socket.on("request lobbies", (map) => {
const jsonMap = JSON.parse(map)
From f88e8e66b4833baa1c52e62dccbd69038e3a97d1 Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 15 Dec 2023 11:03:48 +0100
Subject: [PATCH 3/3] fix du css, et du pb dans lobby :ambulance:
---
cryptide_project/src/Pages/Home.css | 1 -
cryptide_project/src/Pages/Lobbies.tsx | 25 ++++++++++++-------------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/cryptide_project/src/Pages/Home.css b/cryptide_project/src/Pages/Home.css
index 31f01f9..3c06439 100644
--- a/cryptide_project/src/Pages/Home.css
+++ b/cryptide_project/src/Pages/Home.css
@@ -4,7 +4,6 @@
/* background-color: #D7D4C6; */
background-color: #fff;
min-height: 100vh;
- display: flex;
font-size: calc(10px + 2vmin);
/* color: #2A4541; */
}
diff --git a/cryptide_project/src/Pages/Lobbies.tsx b/cryptide_project/src/Pages/Lobbies.tsx
index 8565b88..ca97c3c 100644
--- a/cryptide_project/src/Pages/Lobbies.tsx
+++ b/cryptide_project/src/Pages/Lobbies.tsx
@@ -42,7 +42,7 @@ function Lobbies() {
const [showAvailable, setShowAvailable] = useState(true);
- const [cptNavigation, setCptNavigation] = useState(0);
+ const [cptNavigation, setCptNavigation] = useState(0);
const handleShowAllClick = () => {
setShowAvailable(false);
@@ -56,10 +56,9 @@ function Lobbies() {
setFirst(false);
socket.emit("request lobbies");
};
-
+
const handleSetCptNavigation = () => {
setCptNavigation((prevCpt) => prevCpt + 1);
- const navigationType = useNavigationType();
if (cptNavigation % 2 === 0 && navigationType.toString() === "POP") {
socket.emit("player quit");
@@ -73,25 +72,25 @@ function Lobbies() {
const filteredLobbiesToShow = showAvailable
? filteredLobbies.filter((lobby) => lobby.started == false && lobby.nbPlayer < 6) //* retire les lobbies pleins ou commencés
: filteredLobbies;
-
-
-
+
+
+
const setFirstData = (first: boolean) => {
setFirst(first)
}
- const navigationType = useNavigationType()
-
-
+ const navigationType = useNavigationType();
+
+
handleSetCptNavigation();
-
+
if (first){
handleSetFirst();
}
-
-
-
+
+
+
useEffect(() => {
socket.on("request lobbies", (map) => {
const jsonMap = JSON.parse(map)