diff --git a/ChatServiceApp/js_views.py b/ChatServiceApp/js_views.py index c896c34..5012a84 100644 --- a/ChatServiceApp/js_views.py +++ b/ChatServiceApp/js_views.py @@ -411,7 +411,7 @@ def support_show_chat_by_ticket_ajax(request): Dict.update(get_ticketsDict_for_staff(request.user)) tpl_name = 'blocks/profile/b_support_chat.html' - + Dict.update(get_user_timezone_Dict(request.user, request=request)) html = render_to_string(tpl_name, Dict, request=request) return JsonResponse({'html': html}, status=200) diff --git a/static/js/chat_sockets.js b/static/js/chat_sockets.js index 71dfa3a..1eec052 100644 --- a/static/js/chat_sockets.js +++ b/static/js/chat_sockets.js @@ -39,7 +39,16 @@ function wsReceiveData (e) { console.log(data) } else if (data.type === "update_chat") { let msg_cont = document.querySelector(".container-messages") - + if (getInfoAboutUser('screen_width') < 800){ + if (!window.location.href.includes("chat") && !window.location.href.includes("support")){ + let marker_new_messages = document.querySelector(".marker_messages_mobile"); + if (marker_new_messages.classList.contains('hide')){ + marker_new_messages.classList.add('show') + marker_new_messages.classList.remove('hide') + } + } + } + setCokie(365,'twb_new_messages',true) update_chat_html(data,msg_cont) // document.querySelector(".tab_user_messanger.select").scrollIntoView({behavior: "smooth",block:'end',inline:'end'}); @@ -108,7 +117,7 @@ function wsReceiveData (e) { } if (data.unread_msgs_count > 0){ if (getInfoAboutUser('screen_width') < 800){ - if (!window.location.href.includes("chat") || !window.location.href.includes("chat")){ + if (!window.location.href.includes("chat") && !window.location.href.includes("support")){ let marker_new_messages = document.querySelector(".marker_messages_mobile"); if (marker_new_messages.classList.contains('hide')){ marker_new_messages.classList.add('show') diff --git a/static/js/global_js.js b/static/js/global_js.js index 51fcab7..511719a 100644 --- a/static/js/global_js.js +++ b/static/js/global_js.js @@ -1,4 +1,5 @@ $(document).ready(function (){ + hide_or_show_new_messages_marker() checkStateCookie() }) @@ -12,6 +13,7 @@ window.onload = function (){ openOrCloseCurtainSupportChat() openOverlayOrClose() goToChatIfChat() + // let body = document.querySelector("body") // const viewPortH = body.getBoundingClientRect().height; // const windowH = window.innerHeight; @@ -43,6 +45,14 @@ window.onload = function (){ } } } + +function hide_or_show_new_messages_marker () { + if (getInfoAboutUser('screen_width') < 800){ + if (window.location.href.includes("chat") || window.location.href.includes("support")){ + setCokie(365,'twb_new_messages','false') + } + } +} // function goToChatIfChat () { if (document.querySelector('.block-chat')){ @@ -225,6 +235,14 @@ function checkStateCookie () { marker_new_messages.classList.add('show') } } + } else if (window.document.cookie.includes("twb_new_messages=false")){ + if (getInfoAboutUser('screen_width') < 800) { + let marker_new_messages = document.querySelector(".marker_messages_mobile"); + if (marker_new_messages.classList.contains('show')) { + marker_new_messages.classList.add('hide') + marker_new_messages.classList.remove('show') + } + } } } @@ -246,7 +264,7 @@ function setCokie (days,name,val) { date.setTime(+ date + (days * 86400000)); window.document.cookie = `${name}=${val}` + "; expires=" + date.toGMTString() + "; path=/"; document.querySelector(".cookie_block").classList.remove("show") - return value; + // return value; } function getInCookieTime (time) { diff --git a/static/js/user_profile_2.js b/static/js/user_profile_2.js index 60900bf..ca53a53 100644 --- a/static/js/user_profile_2.js +++ b/static/js/user_profile_2.js @@ -86,7 +86,7 @@ function select_tab_profile (el,url,owner_type=null) { deleteMarkerMessages(el) checkStatesAfterTransitionToAnotherTabProfile() goToChatIfChat() - if (window.location.href.includes("chat") || window.location.href.includes("chat")) { + if (window.location.href.includes("chat") || window.location.href.includes("support")) { if (getInfoAboutUser('screen_width') < 800) { let marker_new_messages = document.querySelector(".marker_messages_mobile"); if (marker_new_messages.classList.contains('show')) {