Node.js based forum software built for the modern web
closes https://github.com/NodeBB/NodeBB/issues/2101
psychobunny91293350b5b5
diff --git a/public/src/forum/footer.js b/public/src/forum/footer.jsindex 94c07caef8..c5db90936a 100644--- a/public/src/forum/footer.js+++ b/public/src/forum/footer.js@@ -24,17 +24,41 @@ define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat).attr('data-content', count > 20 ? '20+' : count);}- function onNewPost(data) {- if (parseInt(app.uid, 10)) {- socket.emit('user.getUnreadCount', updateUnreadTopicCount);+ function prepareUnreadButton() {+ var unreadTopics = {};++ function onNewPost(data) {+ if (data && data.posts && data.posts.length) {+ var post = data.posts[0];++ if (parseInt(post.uid, 10) !== parseInt(app.uid, 10) && !unreadTopics[post.topic.tid]) {+ increaseUnreadCount();+ unreadTopics[post.topic.tid] = true;+ }+ }+ }++ function increaseUnreadCount() {+ var count = parseInt($('#unread-count').attr('data-content'), 10) + 1;+ updateUnreadTopicCount(null, count);}- }- socket.on('event:new_post', onNewPost);+ $(window).on('action:ajaxify.end', function(ev, data) {+ var tid = data.url.match(/^topic\/(\d+)/);++ if (tid && tid[1]) {+ delete unreadTopics[tid[1]];+ }+ });++ socket.on('event:new_post', onNewPost);+ }socket.on('event:unread.updateCount', updateUnreadTopicCount);socket.emit('user.getUnreadCount', updateUnreadTopicCount);socket.on('event:unread.updateChatCount', updateUnreadChatCount);socket.emit('user.getUnreadChatCount', updateUnreadChatCount);++ prepareUnreadButton();});