Node.js based forum software built for the modern web
closes #4611
barisusaklia9828a14650f
diff --git a/public/src/client/recent.js b/public/src/client/recent.jsindex e4223d519a..641beb5ca9 100644--- a/public/src/client/recent.js+++ b/public/src/client/recent.js@@ -35,13 +35,49 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite};function onNewTopic(data) {+ if (ajaxify.data.selectedCategory && parseInt(ajaxify.data.selectedCategory.cid, 10) !== parseInt(data.cid, 10)) {+ return;+ }++ if (ajaxify.data.selectedFilter && ajaxify.data.selectedFilter.url === 'unread/watched') {+ return;+ }+++newTopicCount;Recent.updateAlertText();}function onNewPost(data) {- ++newPostCount;- Recent.updateAlertText();+ function showAlert() {+ ++newPostCount;+ Recent.updateAlertText();+ }++ if (parseInt(data.topic.mainPid, 10) === parseInt(data.posts[0].pid, 10)) {+ return;+ }++ if (ajaxify.data.selectedCategory && parseInt(ajaxify.data.selectedCategory.cid, 10) !== parseInt(data.topic.cid, 10)) {+ return;+ }++ if (ajaxify.data.selectedFilter && ajaxify.data.selectedFilter.url === 'unread/new') {+ return;+ }++ if (ajaxify.data.selectedFilter && ajaxify.data.selectedFilter.url === 'unread/watched') {+ socket.emit('topics.isFollowed', data.topic.tid, function(err, isFollowed) {+ if (err) {+ app.alertError(err.message);+ }+ if (isFollowed) {+ showAlert();+ }+ });+ return;+ }++ showAlert();}Recent.removeListeners = function() {diff --git a/src/controllers/unread.js b/src/controllers/unread.jsindex 1d80774fb0..f0b7471b63 100644--- a/src/controllers/unread.js+++ b/src/controllers/unread.js@@ -78,6 +78,8 @@ unreadController.get = function(req, res, next) {return filter && filter.selected;})[0];+ results.unreadTopics.querystring = req.query.cid ? ('?cid=' + req.query.cid) : '';+res.render('unread', results.unreadTopics);});};diff --git a/src/socket.io/topics.js b/src/socket.io/topics.jsindex 6f5ab296d9..18cad2d980 100644--- a/src/socket.io/topics.js+++ b/src/socket.io/topics.js@@ -88,6 +88,12 @@ function followCommand(method, socket, tid, callback) {method(tid, socket.uid, callback);}+SocketTopics.isFollowed = function(socket, tid, callback) {+ topics.isFollowing([tid], socket.uid, function(err, isFollowing) {+ callback(err, Array.isArray(isFollowing) && isFollowing.length ? isFollowing[0] : false);+ });+};+SocketTopics.search = function(socket, data, callback) {topics.search(data.tid, data.term, callback);};