From 7bed4c40d69b76518141700de5d201504a32aafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 26 May 2015 15:05:46 -0400 Subject: [PATCH] closes #3179 --- public/src/client/unread.js | 2 +- src/socket.io/categories.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/public/src/client/unread.js b/public/src/client/unread.js index 406116e9f1..acb66d4c2f 100644 --- a/public/src/client/unread.js +++ b/public/src/client/unread.js @@ -68,7 +68,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', ' }); }); - socket.emit('categories.get', onCategoriesLoaded); + socket.emit('categories.getWatchedCategories', onCategoriesLoaded); topicSelect.init(); diff --git a/src/socket.io/categories.js b/src/socket.io/categories.js index dd2e130010..5c4b94fa3f 100644 --- a/src/socket.io/categories.js +++ b/src/socket.io/categories.js @@ -18,6 +18,21 @@ SocketCategories.get = function(socket, data, callback) { categories.getCategoriesByPrivilege(socket.uid, 'find', callback); }; +SocketCategories.getWatchedCategories = function(socket, data, callback) { + async.parallel({ + categories: async.apply(categories.getCategoriesByPrivilege, socket.uid, 'find') + ignoredCids: async.apply(user.getIgnoredCategories, socket.uid) + }, function(err, results) { + if (err) { + return callback(err); + } + var watchedCategories = results.categories.filter(function(category) { + return category && results.ignoredCids.indexOf(category.cid.toString()) === -1; + }); + callback(null, watchedCategories); + }); +}; + SocketCategories.loadMore = function(socket, data, callback) { if (!data) { return callback(new Error('[[error:invalid-data]]'));