diff --git a/public/src/forum/footer.js b/public/src/forum/footer.js index e7e8209a1b..c983e0a834 100644 --- a/public/src/forum/footer.js +++ b/public/src/forum/footer.js @@ -24,6 +24,22 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat) .attr('data-content', count > 20 ? '20+' : count); } + function onNewPost(data) { + if (data && data.posts && data.posts.length) { + var post = data.posts[0]; + if (parseInt(post.uid, 10) !== parseInt(app.uid, 10)) { + increaseUnreadCount(); + } + } + } + + function increaseUnreadCount() { + var count = parseInt($('#unread-count').attr('data-content'), 10) + 1; + updateUnreadTopicCount(null, count); + } + + + socket.on('event:new_post', onNewPost); socket.on('event:unread.updateCount', updateUnreadTopicCount); socket.emit('user.getUnreadCount', updateUnreadTopicCount); diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 582e3fa7c9..e7d5e330d3 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -51,14 +51,13 @@ SocketPosts.reply = function(socket, data, callback) { return; } for(var i=0; i