mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
closes #450
backup database before upgrade! upgrade script will take the first post of each topic and set the `mainPid` property on the topic. then it will remove that pid from the sorted sets for that topic, this was done to make alternative sorting work. added a new sorted set called `tid:<id>:posts:votes` that is used to sort topic posts by vote count, the original sorted set `tid:<id>:posts` is used to sort by oldest first or newest first. the main post is added to the returned posts array on topic load and is always at the top. theme changes are minimal just a few new data properties on the posts and the sorting dropdown. hopefully didn't miss anything too critical.
This commit is contained in:
@@ -314,12 +314,22 @@ SocketTopics.loadMore = function(socket, data, callback) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var start = parseInt(data.after, 10),
|
||||
var start = Math.max(parseInt(data.after, 10) - 1, 0),
|
||||
end = start + settings.postsPerPage - 1;
|
||||
|
||||
var set = 'tid:' + data.tid + ':posts',
|
||||
reverse = false;
|
||||
|
||||
if (settings.topicPostSort === 'newest_to_oldest') {
|
||||
reverse = true;
|
||||
} else if (settings.topicPostSort === 'most_votes') {
|
||||
reverse = true;
|
||||
set = 'tid:' + data.tid + ':posts:votes';
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
posts: function(next) {
|
||||
topics.getTopicPosts(data.tid, start, end, socket.uid, false, next);
|
||||
topics.getTopicPosts(data.tid, set, start, end, socket.uid, reverse, next);
|
||||
},
|
||||
privileges: function(next) {
|
||||
privileges.topics.get(data.tid, socket.uid, next);
|
||||
|
||||
Reference in New Issue
Block a user