- disable cha when user is not connected
This commit is contained in:
Kum1ta
2024-09-17 23:21:51 +02:00
parent 965b27426e
commit dbbecc2232
5 changed files with 25 additions and 11 deletions

View File

@ -77,6 +77,7 @@
<h2>X</h2> <h2>X</h2>
</div> </div>
</div> </div>
<p id="infoChat">You are not connected to the chat</p>
</div> </div>
<section class="homeSection"> <section class="homeSection">
</section> </section>

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* main.js :+: :+: :+: */ /* main.js :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: madegryc <madegryc@student.42.fr> +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */ /* Created: 2024/08/25 00:02:19 by edbernar #+# #+# */
/* Updated: 2024/09/17 17:21:27 by madegryc ### ########.fr */ /* Updated: 2024/09/17 23:02:03 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -6,13 +6,14 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */ /* Created: 2024/08/04 19:19:10 by edbernar #+# #+# */
/* Updated: 2024/08/25 18:26:52 by edbernar ### ########.fr */ /* Updated: 2024/09/17 23:10:22 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
import { infoPanel } from "/static/javascript/typeResponse/typePrivateListMessage.js"; import { infoPanel } from "/static/javascript/typeResponse/typePrivateListMessage.js";
import { showActualGameMessage } from "/static/javascript/liveChat/showActualGameMessage.js"; import { showActualGameMessage } from "/static/javascript/liveChat/showActualGameMessage.js";
import { showListUser } from "/static/javascript/liveChat/showUserList.js"; import { showListUser } from "/static/javascript/liveChat/showUserList.js";
import { userMeInfo } from "/static/javascript/typeResponse/typeLogin.js";
/* /*
Todo (Eddy) : Todo (Eddy) :
@ -20,6 +21,7 @@ import { showListUser } from "/static/javascript/liveChat/showUserList.js";
- game message when game will be implemented - game message when game will be implemented
*/ */
let chatContent = null;
let chatButton = null; let chatButton = null;
let topChatHomeCross = null; let topChatHomeCross = null;
@ -86,14 +88,22 @@ function removeButtonIfExist()
async function showChatMenu() async function showChatMenu()
{ {
const infoChat = document.getElementById("infoChat");
chatDiv.style.display = "flex"; chatDiv.style.display = "flex";
removeButtonIfExist(); if (userMeInfo.id !== -1)
addDefaultButton(); {
await showListUser(); if (infoChat)
infoChat.remove();
removeButtonIfExist();
addDefaultButton();
await showListUser();
}
} }
function hideChatMenu() function hideChatMenu()
{ {
console.log("hideChatMenu");
chatDiv.style.display = "none"; chatDiv.style.display = "none";
infoPanel.isOpen = false; infoPanel.isOpen = false;
} }

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/02 00:39:53 by edbernar #+# #+# */ /* Created: 2024/08/02 00:39:53 by edbernar #+# #+# */
/* Updated: 2024/09/14 23:59:52 by edbernar ### ########.fr */ /* Updated: 2024/09/17 22:52:44 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -23,7 +23,7 @@ let loginResolve = null;
function waitForLogin() { function waitForLogin() {
return new Promise((resolve) => { return new Promise((resolve) => {
if (loginAvailable) if (loginAvailable)
resolve(); resolve(userMeInfo);
else else
loginResolve = resolve; loginResolve = resolve;
}); });
@ -58,7 +58,6 @@ function typeLogin(content)
{ {
loginResolve(content); loginResolve(content);
loginResolve = null; loginResolve = null;
loginAvailable = false;
} }
}, 100); }, 100);
} }

View File

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* liveChat.css :+: :+: :+: */ /* liveChat.css :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: madegryc <madegryc@student.42.fr> +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/30 13:53:39 by edbernar #+# #+# */ /* Created: 2024/07/30 13:53:39 by edbernar #+# #+# */
/* Updated: 2024/09/17 18:04:08 by madegryc ### ########.fr */ /* Updated: 2024/09/17 23:12:39 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -238,3 +238,7 @@
} }
} }
#infoChat {
text-align: center;
margin-top: 100px;
}