- new file pour handler request allListUser
    - add function on button new conversation in chat
    - remove cookies from js
Django
    - fix new_msg.sender.id
This commit is contained in:
Kum1ta
2024-08-26 01:27:32 +02:00
parent b08a90226a
commit 1c9e985320
5 changed files with 70 additions and 38 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:17:54 by edbernar #+# #+# */
/* Updated: 2024/08/25 21:24:06 by edbernar ### ########.fr */
/* Updated: 2024/08/26 00:40:11 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -86,7 +86,6 @@ async function displayAllMessage(divMessageListChatHome)
newDiv = document.createElement("div");
contentNode = document.createTextNode(element.content);
dateNode = document.createTextNode(element.date);
console.log(element.from, userMeInfo.id);
newDiv.classList.add(element.from === userMeInfo.id ? "meMessage" : "opponentMessage");
tmp = document.createElement("p");
tmp.classList.add("content");

View File

@ -6,11 +6,12 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 19:21:10 by edbernar #+# #+# */
/* Updated: 2024/08/24 23:31:19 by edbernar ### ########.fr */
/* Updated: 2024/08/26 01:24:28 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { waitForUserList } from "/static/javascript/typeResponse/typePrivateListUser.js";
import { waitForallListUser } from "/static/javascript/typeResponse/typeAllListUser.js";
import { userList } from "/static/javascript/typeResponse/typePrivateListUser.js";
import { showPrivateChat } from "/static/javascript/liveChat/showPrivateChat.js";
import { sendRequest } from "/static/javascript/websocket.js";
@ -41,13 +42,33 @@ async function showListUser() {
divMessageListChatHome.appendChild(user);
});
}
divMessageListChatHome.innerHTML += "<p style='text-align: center; margin-top: 20px;'>New conversation +</p>";
divMessageListChatHome.innerHTML += "<p id='newConversation' style='text-align: center; margin-top: 20px; cursor: pointer;'>New conversation +</p>";
divUser = document.getElementsByClassName("user");
for (let i = 0; i < divUser.length; i++) {
divUser[i].addEventListener("click", async () => {
await showPrivateChat(userList[i]);
});
}
document.getElementById('newConversation').addEventListener('mouseup', () => {
divMessageListChatHome.innerText = 'Loading...';
sendRequest("get_all_list_user", {});
waitForallListUser().then((listUser) => {
divMessageListChatHome.innerText = '';
listUser.forEach(element => {
let user = document.createElement("div");
user.classList.add("user");
user.innerHTML = `
<div class="status ${element.status}">
<img>
</div>
<h3></h3>
`
user.querySelector("img").src = element.pfp;
user.querySelector("h3").innerText = element.name;
divMessageListChatHome.appendChild(user);
})
})
});
}
export { showListUser };