From 114e957b0f4a1ae50ecd4d84bb44fc64d6874dc5 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Fri, 8 Apr 2016 13:54:51 -0500 Subject: [PATCH] add client-side unread count support for the "new" filter --- public/src/client/footer.js | 7 +++++++ src/socket.io/user.js | 1 + 2 files changed, 8 insertions(+) diff --git a/public/src/client/footer.js b/public/src/client/footer.js index d8e54d4fc3..f1d05d4bfe 100644 --- a/public/src/client/footer.js +++ b/public/src/client/footer.js @@ -13,6 +13,12 @@ define('forum/footer', ['notifications', 'chat', 'components', 'translator'], fu .attr('data-content', count > 99 ? '99+' : count); } + function updateUnreadNewTopicCount(count) { + $('#unread-new-count i') + .toggleClass('unread-count', count > 0) + .attr('data-content', count > 99 ? '99+' : count); + } + function updateUnreadChatCount(count) { components.get('chat/icon') .toggleClass('unread-count', count > 0) @@ -61,6 +67,7 @@ define('forum/footer', ['notifications', 'chat', 'components', 'translator'], fu } updateUnreadTopicCount(data.unreadTopicCount); + updateUnreadNewTopicCount(data.unreadNewTopicCount); updateUnreadChatCount(data.unreadChatCount); Notifications.updateNotifCount(data.unreadNotificationCount); }); diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 06acacd520..8ca3e4231e 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -245,6 +245,7 @@ SocketUser.getUnreadCounts = function(socket, data, callback) { } async.parallel({ unreadTopicCount: async.apply(topics.getTotalUnread, socket.uid), + unreadNewTopicCount: async.apply(topics.getTotalUnread, socket.uid, 'new'), unreadChatCount: async.apply(messaging.getUnreadCount, socket.uid), unreadNotificationCount: async.apply(user.notifications.getUnreadCount, socket.uid) }, callback);