diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index 91c44e7..4bf423d 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -46,12 +46,19 @@ url = `ws://localhost:8000/ws/socket-server/?user_id=${user_id}`; const chatSocket = new WebSocket(url); + function sendMessageSocket (data) { chatSocket.send(JSON.stringify(data)); } chatSocket.onmessage = function (e) { + let el_tab = document.querySelector(".tab_user_messanger.select") + let old_item_tab_user = null; + if (el_tab !== null){ + let dataset = el_tab.dataset; + old_item_tab_user = dataset['curReceiverItem']; + } let data = JSON.parse(e.data); console.log('Data:', data); console.log("return") @@ -68,8 +75,15 @@ chatSocket.onmessage = function (e) { } } - if (data.users_list_html){ - document.querySelector(".block-list-of-users").innerHTML = data.users_list_html + let list_of_users = document.querySelector(".block-list-of-users") + if (list_of_users !== null){ + if (data.users_list_html){ + list_of_users.innerHTML = data.users_list_html + if (el_tab !== null){ + document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]` ).classList.add("select") + } + } + } } if (data.required_beep === true) { diff --git a/templates/widgets/w_chat_right_panel_user.html b/templates/widgets/w_chat_right_panel_user.html index 3c9c33a..f8e5559 100644 --- a/templates/widgets/w_chat_right_panel_user.html +++ b/templates/widgets/w_chat_right_panel_user.html @@ -1,5 +1,5 @@ {% load static %} -
+