Node.js based forum software built for the modern web
nextStart changes, fixed move topic notification text
barisusakli6aa53b83233d
diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.jsonindex 3cb6ac6872..6e35eac76a 100644--- a/public/language/en_GB/notifications.json+++ b/public/language/en_GB/notifications.json@@ -13,8 +13,8 @@"new_message_from": "New message from <strong>%1</strong>","upvoted_your_post_in": "<strong>%1</strong> has upvoted your post in <strong>%2</strong>.",- "moved_your_post": "<strong>%1<strong> has moved your post.",- "moved_your_topic": "<strong>%1<strong> has moved your topic.",+ "moved_your_post": "<strong>%1</strong> has moved your post.",+ "moved_your_topic": "<strong>%1</strong> has moved your topic.","favourited_your_post_in": "<strong>%1</strong> has favourited your post in <strong>%2</strong>.","user_flagged_post_in": "<strong>%1</strong> flagged a post in <strong>%2</strong>","user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",diff --git a/src/categories.js b/src/categories.jsindex 2a80c4a67b..f6599d64ad 100644--- a/src/categories.js+++ b/src/categories.js@@ -114,7 +114,7 @@ var db = require('./database'),topics.getTopicsByTids(tids, uid, next);},function(topics, next) {- if (!topics || !topics.length) {+ if (!Array.isArray(topics) || !topics.length) {return next(null, {topics: [],nextStart: 1@@ -131,15 +131,9 @@ var db = require('./database'),topics[i].index = indices[topics[i].tid];}- db.sortedSetRevRank('categories:' + cid + ':tid', topics[topics.length - 1].tid, function(err, rank) {- if(err) {- return next(err);- }-- next(null, {- topics: topics,- nextStart: parseInt(rank, 10) + 1- });+ next(null, {+ topics: topics,+ nextStart: stop + 1});}], callback);diff --git a/src/controllers/tags.js b/src/controllers/tags.jsindex 755ede4b91..53b418f6b9 100644--- a/src/controllers/tags.js+++ b/src/controllers/tags.js@@ -42,6 +42,7 @@ tagsController.getTag = function(req, res, next) {];data.tag = tag;+ data.nextStart = end + 1;res.render('tag', data);});});diff --git a/src/messaging.js b/src/messaging.jsindex e47270d5da..4547c1d981 100644--- a/src/messaging.js+++ b/src/messaging.js@@ -260,13 +260,7 @@ var db = require('./database'),}});- db.sortedSetRevRank('uid:' + uid + ':chats', results.users[results.users.length - 1].uid, function(err, rank) {- if (err) {- return callback(err);- }-- callback(null, {users: results.users, nextStart: rank + 1});- });+ callback(null, {users: results.users, nextStart: end + 1});});});};diff --git a/src/posts.js b/src/posts.jsindex d9743e0642..6d6089f732 100644--- a/src/posts.js+++ b/src/posts.js@@ -469,7 +469,12 @@ var async = require('async'),if (err) {return callback(err);}- getPostsFromSet('uid:' + uid + ':posts', pids, callerUid, callback);+ getPosts(pids, callerUid, function(err, posts) {+ if (err) {+ return callback(err);+ }+ callback(null, {posts: posts, nextStart: end + 1});+ });});});};@@ -480,13 +485,18 @@ var async = require('async'),return callback(err);}- getPostsFromSet('uid:' + uid + ':favourites', pids, uid, callback);+ getPosts(pids, uid, function(err, posts) {+ if (err) {+ return callback(err);+ }+ callback(null, {posts: posts, nextStart: end + 1});+ });});};- function getPostsFromSet(set, pids, uid, callback) {+ function getPosts(pids, uid, callback) {if (!Array.isArray(pids) || !pids.length) {- return callback(null, {posts: [], nextStart: 0});+ return callback(null, []);}Posts.getPostSummaryByPids(pids, uid, {stripTags: false}, function(err, posts) {@@ -495,19 +505,10 @@ var async = require('async'),}if (!Array.isArray(posts) || !posts.length) {- return callback(null, {posts: [], nextStart: 0});+ return callback(null, []);}- db.sortedSetRevRank(set, posts[posts.length - 1].pid, function(err, rank) {- if(err) {- return callback(err);- }- var data = {- posts: posts,- nextStart: parseInt(rank, 10) + 1- };- callback(null, data);- });+ callback(null, posts);});}diff --git a/src/topics.js b/src/topics.jsindex da8ffb4776..3cfdd959a1 100644--- a/src/topics.js+++ b/src/topics.js@@ -140,34 +140,34 @@ var async = require('async'),}Topics.getTopicsByTids(tids, uid, function(err, topicData) {- if(err) {+ if (err) {return callback(err);}- if(!topicData || !topicData.length) {+ if(!Array.isArray(topicData) || !topicData.length) {return callback(null, returnTopics);}- db.sortedSetRevRank(set, topicData[topicData.length - 1].tid, function(err, rank) {- if(err) {- return callback(err);- }-- returnTopics.nextStart = parseInt(rank, 10) + 1;- returnTopics.topics = topicData;- callback(null, returnTopics);- });+ returnTopics.topics = topicData;+ callback(null, returnTopics);});});};Topics.getTopicsFromSet = function(uid, set, start, end, callback) {db.getSortedSetRevRange(set, start, end, function(err, tids) {- if(err) {+ if (err) {return callback(err);}- Topics.getTopics(set, uid, tids, callback);+ Topics.getTopics(set, uid, tids, function(err, data) {+ if (err) {+ return callback(err);+ }++ data.nextStart = end + 1;+ callback(null, data);+ });});};diff --git a/src/topics/recent.js b/src/topics/recent.jsindex e94dbe23a8..c8b6b551bc 100644--- a/src/topics/recent.js+++ b/src/topics/recent.js@@ -17,11 +17,18 @@ module.exports = function(Topics) {Topics.getLatestTopics = function(uid, start, end, term, callback) {Topics.getLatestTids(start, end, term, function(err, tids) {- if(err) {+ if (err) {return callback(err);}- Topics.getTopics('topics:recent', uid, tids, callback);+ Topics.getTopics('topics:recent', uid, tids, function(err, data) {+ if (err) {+ return callback(err);+ }++ data.nextStart = end + 1;+ callback(null, data);+ });});};diff --git a/src/topics/unread.js b/src/topics/unread.jsindex 7777f82ae5..4e8bc509d2 100644--- a/src/topics/unread.js+++ b/src/topics/unread.js@@ -45,16 +45,10 @@ module.exports = function(Topics) {return callback(null, unreadTopics);}- db.sortedSetRevRank('topics:recent', topicData[topicData.length - 1].tid, function(err, rank) {- if (err) {- return callback(err);- }+ unreadTopics.topics = topicData;+ unreadTopics.nextStart = stop + 1;- unreadTopics.topics = topicData;- unreadTopics.nextStart = parseInt(rank, 10) + 1;-- callback(null, unreadTopics);- });+ callback(null, unreadTopics);});});};