@agarcia17 Yes I did but then I deleted it because I changed the way I displayed my menu after some feedback.
But here's what I've done
//Check if there's unread messages
var unread = setTimeout(checkUnread,500);
//Update Unread messages on events
socket.on('event:chats.receive', function(data) {toggleUnread(data)});
socket.on('event:new_notification', toggleUnread);
socket.on('event:new_post', toggleUnread);
socket.on('event:new_topic', toggleUnread);
function toggleUnread(data) {
if (data) var receptor = data.message.touid;
if (!$('#unread').length) {
var unread = '<span id="unread" title="Vous avez des messages non lus" class="bounce-small infinite animated">';
if (receptor != undefined) {
if (receptor == window.app.uid) $(unread).insertAfter('.header-top .menu');
} else {
$(unread).insertAfter('.header-top .menu');
}
}
}
function checkUnread() {
$('#unread-count, #notif_dropdown i, #chat-count').each(function(){
var n = $(this).attr('data-content')
if (n > 0) {
toggleUnread();
return false;
}
});
}
I hope it can help you.