This commit is contained in:
2023-08-09 13:54:47 +03:00
parent f8ed2b6fd2
commit c3e42dbe33
3 changed files with 31 additions and 2 deletions

View File

@@ -20,7 +20,9 @@ function check_new_messages_timeout(){
}
check_msg = setInterval(function () {
sessionStorage.setItem('online',user_online)
let new_message = getNewMessageSession()
let user_online = userOnline('set')
window = document.querySelector(".container-messages")
if (window === null){
//
@@ -29,7 +31,7 @@ function check_new_messages_timeout(){
check_new_messages(window,it)
}
},
1000)
60000)
}
@@ -58,6 +60,7 @@ function check_new_messages (window,it){
data_new_messages.last_message_modifiedDT = last_message_time.dataset['modifieddt']
}
$.ajax({
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
url: '/ru/messages/update_chat/',
@@ -110,3 +113,16 @@ function success_check_new_messages (data) {
}
function userOnline (set=null,check=null) {
let user_online = null
if (set !== null){
user_online = navigator.userActivation.isActive || navigator.userActivation.hasBeenActive === true;
sessionStorage.setItem('online',user_online)
} else if (check !== null){
user_online = navigator.userActivation.isActive || navigator.userActivation.hasBeenActive === true;
sessionStorage.getItem('online')
}
return user_online
}

11
static/js/global_js.js Normal file
View File

@@ -0,0 +1,11 @@
$(document).ready(function (){
getNewMessageSession()
})
function getNewMessageSession (){
let new_message = JSON.parse(
sessionStorage.getItem('user_alerts')
)
return new_message
}

View File

@@ -13,6 +13,8 @@
<link rel="stylesheet" href="{% static 'css/styles(boris).css' %}" >
<script src="{% static "js/global_js.js" %}"></script>
{% block meta %}