Skip to content

Node.js based forum software built for the modern web

doing it properly this time

barisusakli1cf5c3145a22
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<posts.length; ++i) {
+ posts[i].index = start + i;
+ }
+ posts[0].index = 0;
+ Topics.addPostData(posts, uid, next);
+ });
+ });
+ },
category: function(next) {
Topics.getCategoryData(tid, next);
},
@@ -280,7 +294,7 @@ var async = require('async'),
}
topicData.category = results.category;
- topicData.posts = results.mainPost.concat(results.posts);
+ topicData.posts = results.posts;
topicData.tags = results.tags;
topicData.thread_tools = results.threadTools;
topicData.pageCount = results.pageCount;