Move unread chat count to one request
This commit is contained in:
parent
a7f7aab444
commit
bddb00050a
5 changed files with 40 additions and 48 deletions
|
@ -158,20 +158,6 @@
|
|||
id: '{{ request.user.id|escapejs }}',
|
||||
name: '{{ request.user.username|escapejs }}'
|
||||
};
|
||||
$(function() {
|
||||
if ($('#chat-icon').length) {
|
||||
$.get("{{url('get_unread_boxes')}}")
|
||||
.done(function(data) {
|
||||
if (data.unread_boxes) {
|
||||
var html = `<sub class="unread_boxes">${data.unread_boxes}</sub>`;
|
||||
$('#chat-icon').append(html);
|
||||
}
|
||||
})
|
||||
.fail(function(data) {
|
||||
console.log('Fail to get unread boxes');
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% else %}
|
||||
<script>window.user = {};</script>
|
||||
|
@ -230,6 +216,10 @@
|
|||
<span class="navbar-icons">
|
||||
<span title="{{_('Chat')}}">
|
||||
<a id="chat-icon" href="{{ url('chat', '') }}" class="icofont-wechat navbar-icon" aria-hidden="true">
|
||||
{% set unread_chat = request.profile.count_unread_chat_boxes %}
|
||||
{% if unread_chat %}
|
||||
<sub class="unread_boxes">{{unread_chat}}</sub>
|
||||
{% endif %}
|
||||
</a>
|
||||
</span>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue