diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index b89d013..2c83d94 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -93,9 +93,15 @@ chatSocket.onmessage = function (e) { if (document.querySelector(".list_linked_tickets") !== null || document.querySelector(".list_unlinked_tickets") !== null) { document.querySelector(".list_unlinked_tickets").innerHTML = data.tickets_wo_manager_html if (el_tab !== null) { - document.querySelector(".tab_user_messanger.select").classList.remove("select") - document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`).classList.add("select") - document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`).scrollIntoView({behavior: "smooth"}); + let select_tab = document.querySelector(".tab_user_messanger.select") + if (select_tab) { + select_tab.classList.remove("select") + } + let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`) + if (old_insert_tab) { + old_insert_tab.classList.add("select") + old_insert_tab.scrollIntoView({behavior: "smooth"}); + } } } @@ -105,8 +111,11 @@ chatSocket.onmessage = function (e) { document.querySelector(".list_linked_tickets").innerHTML = data.tickets_w_manager_html if (el_tab !== null){ document.querySelector(".tab_user_messanger.select").classList.remove("select") - document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]` ).classList.add("select") - document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]` ).scrollIntoView({behavior: "smooth"}); + let old_insert_tab = document.querySelector(`[data-cur-receiver-item="${old_item_tab_user}"]`) + if (old_insert_tab) { + old_insert_tab.classList.add("select") + old_insert_tab.scrollIntoView({behavior: "smooth"}); + } } }