Add chat notification to navbar

This commit is contained in:
cuom1999 2021-11-21 21:01:35 -06:00
parent 9d1f71513e
commit 7c3e59feec
4 changed files with 43 additions and 1 deletions

View file

@ -150,6 +150,20 @@
id: '{{ request.user.id|escapejs }}',
name: '{{ request.user.username|escapejs }}'
};
$(function() {
if ($('.nav-chat').length) {
$.get("{{url('get_unread_boxes')}}")
.done(function(data) {
if (data.unread_boxes) {
var html = `<sub class="unread_boxes">${data.unread_boxes}</sub>`;
$('.nav-chat').append(html);
}
})
.fail(function(data) {
console.log('Fail to get unread boxes');
});
}
});
</script>
{% else %}
<script>window.user = {};</script>