- fix some bug on chat
Game
    - fix some bugs for action 7
This commit is contained in:
Kum1ta
2024-09-22 18:01:53 +02:00
parent 0004d2107f
commit b7332b178f
4 changed files with 30 additions and 20 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:17:54 by edbernar #+# #+# */
/* Updated: 2024/09/21 17:14:15 by edbernar ### ########.fr */
/* Updated: 2024/09/22 17:16:00 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -38,11 +38,14 @@ function changeButton(user)
const divMessageListChatHome = document.getElementById("messageListChatHome");
const h2Username = document.createElement("h2");
const h2UsernameNode = document.createTextNode(user.name);
const buttonTypeChatHome = document.getElementById('buttonTypeChatHome');
const div = document.createElement('div');
let returnButton = null;
if (buttonTypeChatHome)
buttonTypeChatHome.remove();
divMessageListChatHome.before(div);
div.innerHTML += `
div.innerHTML = `
<p id="returnButton" style="margin: 8px 10px 0 0; text-align: right;">Return</p>
`;
div.setAttribute('id', 'buttonTypeChatHome');

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:21:10 by edbernar #+# #+# */
/* Updated: 2024/09/21 17:15:11 by edbernar ### ########.fr */
/* Updated: 2024/09/22 17:37:10 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,13 +20,20 @@ function showListUser() {
const buttons = document.getElementById('buttonTypeChatHome');
const infoChat = document.getElementById("infoChat");
const divMessageListChatHome = document.getElementById("messageListChatHome");
let divUser;
let userList;
const inputMessageDiv = document.getElementById("inputMessageDiv");
let listUser;
sendRequest("get_private_list_user", {});
waitForUserList().then((userList) => {
if (buttons)
buttons.remove();
if (inputMessageDiv)
inputMessageDiv.remove();
if (!userList.length)
infoChat.innerText = "No conversation"
{
if (infoChat)
infoChat.innerText = "No conversation"
}
else
{
divMessageListChatHome.style.height = "100%";
@ -35,8 +42,6 @@ function showListUser() {
divMessageListChatHome.scrollTop = 0;
if (infoChat)
infoChat.remove();
if (buttons)
buttons.remove();
userList.forEach(element => {
let user = document.createElement("div");
user.classList.add("user");
@ -50,9 +55,9 @@ function showListUser() {
user.querySelector("h3").innerText = element.name;
divMessageListChatHome.appendChild(user);
});
divUser = divMessageListChatHome.children;
for (let i = 0; i < divUser.length; i++) {
divUser[i].addEventListener("click", async () => {
listUser = divMessageListChatHome.children;
for (let i = 0; i < listUser.length; i++) {
listUser[i].addEventListener("click", async () => {
showPrivateChat(userList[i]);
});
}