Add chat notification to navbar
This commit is contained in:
parent
9d1f71513e
commit
7c3e59feec
4 changed files with 43 additions and 1 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue