Merge pull request 'sonarSmells' (#110) from sonarSmells into master
continuous-integration/drone/push Build is passing Details

Reviewed-on: #110
pull/115/head
Pierre FERREIRA 1 year ago
commit e94001ce1d

@ -4,7 +4,6 @@
/* background-color: #D7D4C6; */ /* background-color: #D7D4C6; */
background-color: #fff; background-color: #fff;
min-height: 100vh; min-height: 100vh;
display: flex;
font-size: calc(10px + 2vmin); font-size: calc(10px + 2vmin);
/* color: #2A4541; */ /* color: #2A4541; */
} }

@ -28,7 +28,7 @@ class LobbyDataProps {
} }
} }
let cptNavigation = 0 // let cptNavigation = 0
function Lobbies() { function Lobbies() {
const theme=useTheme(); const theme=useTheme();
@ -42,6 +42,8 @@ function Lobbies() {
const [showAvailable, setShowAvailable] = useState(true); const [showAvailable, setShowAvailable] = useState(true);
const [cptNavigation, setCptNavigation] = useState(0);
const handleShowAllClick = () => { const handleShowAllClick = () => {
setShowAvailable(false); setShowAvailable(false);
}; };
@ -50,7 +52,18 @@ function Lobbies() {
setShowAvailable(true); setShowAvailable(true);
}; };
const handleSetFirst = () => {
setFirst(false);
socket.emit("request lobbies");
};
const handleSetCptNavigation = () => {
setCptNavigation((prevCpt) => prevCpt + 1);
if (cptNavigation % 2 === 0 && navigationType.toString() === "POP") {
socket.emit("player quit");
}
};
const filteredLobbies = lobbyData.filter((lobby) => const filteredLobbies = lobbyData.filter((lobby) =>
lobby.roomNum.toLowerCase().includes(searchTerm.toLowerCase()) || lobby.roomNum.toLowerCase().includes(searchTerm.toLowerCase()) ||
lobby.headPlayer.pseudo.toLowerCase().includes(searchTerm.toLowerCase()) lobby.headPlayer.pseudo.toLowerCase().includes(searchTerm.toLowerCase())
@ -66,19 +79,18 @@ function Lobbies() {
setFirst(first) setFirst(first)
} }
const navigationType = useNavigationType() const navigationType = useNavigationType();
cptNavigation++
if (cptNavigation % 2 == 0){
if (navigationType.toString() == "POP"){
socket.emit("player quit") handleSetCptNavigation();
}
}
if (first){ if (first){
setFirst(false) handleSetFirst();
socket.emit("request lobbies")
} }
useEffect(() => { useEffect(() => {
socket.on("request lobbies", (map) => { socket.on("request lobbies", (map) => {
const jsonMap = JSON.parse(map) const jsonMap = JSON.parse(map)

Loading…
Cancel
Save