mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #4611
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user