mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
doing it properly this time
mainPost always has index 0
This commit is contained in:
@@ -76,7 +76,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topic.toTop = function() {
|
Topic.toTop = function() {
|
||||||
navigator.scrollTop(1);
|
navigator.scrollTop(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topic.toBottom = function() {
|
Topic.toBottom = function() {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
|
|||||||
|
|
||||||
navigator.scrollTop = function(index) {
|
navigator.scrollTop = function(index) {
|
||||||
if ($('li[data-index="' + index + '"]').length) {
|
if ($('li[data-index="' + index + '"]').length) {
|
||||||
navigator.scrollUp();
|
navigator.scrollToPost(index, true);
|
||||||
} else {
|
} else {
|
||||||
ajaxify.go(generateUrl());
|
ajaxify.go(generateUrl());
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ define('navigator', ['forum/pagination'], function(pagination) {
|
|||||||
|
|
||||||
navigator.scrollBottom = function(index) {
|
navigator.scrollBottom = function(index) {
|
||||||
if ($('li[data-index="' + index + '"]').length) {
|
if ($('li[data-index="' + index + '"]').length) {
|
||||||
navigator.scrollDown();
|
navigator.scrollToPost(index, true);
|
||||||
} else {
|
} else {
|
||||||
index = parseInt(index, 10) + 1;
|
index = parseInt(index, 10) + 1;
|
||||||
ajaxify.go(generateUrl(index));
|
ajaxify.go(generateUrl(index));
|
||||||
|
|||||||
@@ -256,11 +256,25 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
mainPost: function(next) {
|
|
||||||
Topics.getMainPost(tid, uid, next);
|
|
||||||
},
|
|
||||||
posts: function(next) {
|
posts: function(next) {
|
||||||
Topics.getTopicPosts(tid, set, start, end, uid, reverse, 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) {
|
category: function(next) {
|
||||||
Topics.getCategoryData(tid, next);
|
Topics.getCategoryData(tid, next);
|
||||||
@@ -280,7 +294,7 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
topicData.category = results.category;
|
topicData.category = results.category;
|
||||||
topicData.posts = results.mainPost.concat(results.posts);
|
topicData.posts = results.posts;
|
||||||
topicData.tags = results.tags;
|
topicData.tags = results.tags;
|
||||||
topicData.thread_tools = results.threadTools;
|
topicData.thread_tools = results.threadTools;
|
||||||
topicData.pageCount = results.pageCount;
|
topicData.pageCount = results.pageCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user