Node.js based forum software built for the modern web
fixing #1587 properly for unread count
psychobunny791fde7904f8
diff --git a/public/src/forum/topic.js b/public/src/forum/topic.jsindex 309acb2066..834880dec2 100644--- a/public/src/forum/topic.js+++ b/public/src/forum/topic.js@@ -73,6 +73,9 @@ define(['forum/pagination', 'forum/infinitescroll', 'forum/topic/threadTools', '$(window).on('scroll', updateTopicTitle);$(window).trigger('action:topic.loaded');++ socket.emit('topics.markAsRead', {tid: tid, uid: app.uid});+ socket.emit('topics.increaseViewCount', tid);};function showBottomPostBar() {diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex fadfc47fba..f9a87d2d79 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -162,18 +162,6 @@ topicsController.get = function(req, res, next) {topic_url += '?' + queryString;}-- if (!req.query.prefetched) {- topics.increaseViewCount(tid);-- if (uid) {- topics.markAsRead(tid, uid, function(err) {- topics.pushUnreadCount(uid);- topics.markTopicNotificationsRead(tid, uid);- });- }- }-// Paginator for noscriptdata.pages = [];for(var x=1; x<=data.pageCount; x++) {diff --git a/src/socket.io/topics.js b/src/socket.io/topics.jsindex 43951f707b..e2a4aba1a1 100644--- a/src/socket.io/topics.js+++ b/src/socket.io/topics.js@@ -57,6 +57,10 @@ SocketTopics.postcount = function(socket, tid, callback) {topics.getTopicField(tid, 'postcount', callback);};+SocketTopics.increaseViewCount = function(socket, tid) {+ topics.increaseViewCount(tid);+}+SocketTopics.markAsRead = function(socket, data) {if(!data || !data.tid || !data.uid) {return;diff --git a/src/socket.io/user.js b/src/socket.io/user.jsindex f6e88c26e4..1d84193b64 100644--- a/src/socket.io/user.js+++ b/src/socket.io/user.js@@ -27,7 +27,7 @@ SocketUser.emailExists = function(socket, data, callback) {SocketUser.increaseViewCount = function(socket, uid, callback) {if (uid) {if (socket.uid !== parseInt(uid, 10)) {- user.incrementUserFieldBy(uid, 'profileviews', 1);+ user.incrementUserFieldBy(uid, 'profileviews', 1, callback);}}};