From 1cf5c3145a222049145f33585c8b9bfaea703a0b Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 12 Aug 2014 12:32:38 -0400 Subject: [PATCH] doing it properly this time mainPost always has index 0 --- public/src/forum/topic.js | 2 +- public/src/modules/navigator.js | 4 ++-- src/topics.js | 28 +++++++++++++++++++++------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 06d0167a53..3df4a2b1c3 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -76,7 +76,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT }; Topic.toTop = function() { - navigator.scrollTop(1); + navigator.scrollTop(0); }; Topic.toBottom = function() { diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index bc1bf3e2b8..88e3934128 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -110,7 +110,7 @@ define('navigator', ['forum/pagination'], function(pagination) { navigator.scrollTop = function(index) { if ($('li[data-index="' + index + '"]').length) { - navigator.scrollUp(); + navigator.scrollToPost(index, true); } else { ajaxify.go(generateUrl()); } @@ -118,7 +118,7 @@ define('navigator', ['forum/pagination'], function(pagination) { navigator.scrollBottom = function(index) { if ($('li[data-index="' + index + '"]').length) { - navigator.scrollDown(); + navigator.scrollToPost(index, true); } else { index = parseInt(index, 10) + 1; ajaxify.go(generateUrl(index)); diff --git a/src/topics.js b/src/topics.js index ab3f4f6ffa..926f8bb78b 100644 --- a/src/topics.js +++ b/src/topics.js @@ -256,12 +256,26 @@ var async = require('async'), } async.parallel({ - mainPost: function(next) { - Topics.getMainPost(tid, uid, next); - }, - posts: function(next) { - Topics.getTopicPosts(tid, set, start, end, uid, reverse, next); - }, + posts: function(next) { + posts.getPidsFromSet(set, start, end, reverse, function(err, pids) { + if (err) { + return next(err); + } + + pids = [topicData.mainPid].concat(pids); + posts.getPostsByPids(pids, tid, function(err, posts) { + if (err) { + return next(err); + } + start = parseInt(start, 10); + for(var i=0; i