diff --git a/docker-compose/requirements/nginx/static/javascript/liveChat/main.js b/docker-compose/requirements/nginx/static/javascript/liveChat/main.js index 86556c2..8ae29ba 100644 --- a/docker-compose/requirements/nginx/static/javascript/liveChat/main.js +++ b/docker-compose/requirements/nginx/static/javascript/liveChat/main.js @@ -6,12 +6,12 @@ /* By: edbernar { + try { + userListUnread.splice(userListUnread.indexOf(user.id), 1); + } + catch (e) {}; infoPanel.id = user.id; infoPanel.isOpen = true; infoPanel.divMessage = divMessageListChatHome; + sendRequest("read_message", {id: user.id}); changeButton(user); displayAllMessage(divMessageListChatHome); displayInputBar(divMessageListChatHome, user); - }) } diff --git a/docker-compose/requirements/nginx/static/javascript/liveChat/showUserList.js b/docker-compose/requirements/nginx/static/javascript/liveChat/showUserList.js index 7f0d747..3d65702 100644 --- a/docker-compose/requirements/nginx/static/javascript/liveChat/showUserList.js +++ b/docker-compose/requirements/nginx/static/javascript/liveChat/showUserList.js @@ -6,7 +6,7 @@ /* By: edbernar - +

` + if (element.haveUnread) + { + user.innerHTML += ``; + user.querySelector("span").style.marginLeft = "auto"; + } user.querySelector("img").src = element.pfp; user.querySelector("h3").innerText = element.name; divMessageListChatHome.appendChild(user); diff --git a/docker-compose/requirements/nginx/static/javascript/typeResponse/typeLogin.js b/docker-compose/requirements/nginx/static/javascript/typeResponse/typeLogin.js index af2e165..388ea7a 100644 --- a/docker-compose/requirements/nginx/static/javascript/typeResponse/typeLogin.js +++ b/docker-compose/requirements/nginx/static/javascript/typeResponse/typeLogin.js @@ -6,7 +6,7 @@ /* By: edbernar { - const popout = document.getElementById('loginPopup'); - const loginButton = document.getElementById('loginButton'); - let pLoginButton = null; - if (loginButton) - pLoginButton = loginButton.getElementsByTagName('p')[0]; - let usernameNode = null; - - - if (content && typeof(content) != 'boolean' && content.status == true) - { - console.log("Welcome " + content.username + "\nYour id is " + content.id); - userMeInfo.username = content.username; - userMeInfo.id = content.id; - if (popout && popout.style.display === 'flex') + const popout = document.getElementById('loginPopup'); + const loginButton = document.getElementById('loginButton'); + let pLoginButton = loginButton ? loginButton.getElementsByTagName('p')[0] : null; + let notifBadgeChat = null; + let usernameNode = null; + let interval = null; + let i = 0; + + if (content && typeof(content) != 'boolean' && content.status == true) + { + console.log("Welcome " + content.username + "\nYour id is " + content.id); + userMeInfo.username = content.username; + userMeInfo.id = content.id; + + interval = setInterval(() => { + notifBadgeChat = document.getElementsByClassName('notification-badge')[0]; + if (notifBadgeChat && content.haveUnredMessage) { - usernameNode = document.createTextNode(userMeInfo.username); - loginButton.replaceChild(usernameNode, pLoginButton); - CN.new("Connected successfully", "Welcome " + userMeInfo.username, CN.defaultIcon.success); - popout.style.display = 'none'; + console.log("You have unread messages"); + notifBadgeChat.style.display = 'flex'; + clearInterval(interval); } - } - loginAvailable = true; - if (loginResolve != []) + else if (notifBadgeChat) + clearInterval(interval); + else if (i == 5) + clearInterval(interval); + i++; + }, 500); + if (popout && popout.style.display === 'flex') { - loginResolve.forEach(func => func(content)); - loginResolve = []; + usernameNode = document.createTextNode(userMeInfo.username); + loginButton.replaceChild(usernameNode, pLoginButton); + CN.new("Connected successfully", "Welcome " + userMeInfo.username, CN.defaultIcon.success); + popout.style.display = 'none'; } - // }, 100); + } + loginAvailable = true; + if (loginResolve != []) + { + loginResolve.forEach(func => func(content)); + loginResolve = []; + } } export { userMeInfo, typeLogin, waitForLogin }; \ No newline at end of file diff --git a/docker-compose/requirements/nginx/static/javascript/typeResponse/typeNewPrivateMessage.js b/docker-compose/requirements/nginx/static/javascript/typeResponse/typeNewPrivateMessage.js index d7dd1cd..04bebe8 100644 --- a/docker-compose/requirements/nginx/static/javascript/typeResponse/typeNewPrivateMessage.js +++ b/docker-compose/requirements/nginx/static/javascript/typeResponse/typeNewPrivateMessage.js @@ -6,7 +6,7 @@ /* By: edbernar @@ -31,6 +35,7 @@ function typeNewPrivateMessage(content) } else if (content.from != userMeInfo.id) { + notifBadgeChat.style.display = 'flex'; sendRequest("get_user_info", {id: content.from}); waitForUserInfo().then((userInfo) => { CN.new("Message", "New message from " + userInfo.username); diff --git a/docker-compose/requirements/nginx/static/javascript/typeResponse/typePrivateListUser.js b/docker-compose/requirements/nginx/static/javascript/typeResponse/typePrivateListUser.js index 13da394..bde8f95 100644 --- a/docker-compose/requirements/nginx/static/javascript/typeResponse/typePrivateListUser.js +++ b/docker-compose/requirements/nginx/static/javascript/typeResponse/typePrivateListUser.js @@ -6,13 +6,14 @@ /* By: edbernar { @@ -28,6 +29,12 @@ function waitForUserList() { function typePrivateListUser(list) { userList = list; + userListUnread = []; + userList.forEach(element => { + if (element.haveUnread) + userListUnread.push(element.id); + }); + console.log(userListUnread); userListAvailable = true; if (userListResolve) { @@ -37,4 +44,4 @@ function typePrivateListUser(list) { } } -export { userList, typePrivateListUser, waitForUserList }; \ No newline at end of file +export { userList, userListUnread, typePrivateListUser, waitForUserList }; \ No newline at end of file diff --git a/docker-compose/requirements/nginx/static/style/global/global.css b/docker-compose/requirements/nginx/static/style/global/global.css index 5458a51..51c3b2a 100644 --- a/docker-compose/requirements/nginx/static/style/global/global.css +++ b/docker-compose/requirements/nginx/static/style/global/global.css @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* global.css :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: madegryc +#+ +:+ +#+ */ +/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar