mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 02:20:49 +01:00
scroll to posts
This commit is contained in:
@@ -24,9 +24,7 @@ var RDB = require('./redis.js'),
|
||||
callback(posts);
|
||||
});
|
||||
} else {
|
||||
callback({
|
||||
error: 'no-posts'
|
||||
});
|
||||
callback([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ marked.setOptions({
|
||||
|
||||
Topics.getTopicPosts = function(tid, start, end, current_user, callback) {
|
||||
posts.getPostsByTid(tid, start, end, function(postData) {
|
||||
|
||||
if(Array.isArray(postData) && !postData.length)
|
||||
return callback([]);
|
||||
|
||||
function getFavouritesData(next) {
|
||||
var pids = [];
|
||||
for(var i=0; i<postData.length; ++i)
|
||||
@@ -78,7 +80,7 @@ marked.setOptions({
|
||||
postData[i].fav_star_class = fav_data[postData[i].pid] ? 'icon-star' : 'icon-star-empty';
|
||||
postData[i]['display_moderator_tools'] = (postData[i].uid == current_user || privileges.editable) ? 'show' : 'none';
|
||||
}
|
||||
|
||||
|
||||
callback(postData);
|
||||
});
|
||||
});
|
||||
@@ -279,8 +281,7 @@ marked.setOptions({
|
||||
}
|
||||
|
||||
function getTopicPosts(next) {
|
||||
Topics.getTopicPosts(tid, 0, -1, current_user, function(topicPosts, privileges) {
|
||||
|
||||
Topics.getTopicPosts(tid, 0, 10, current_user, function(topicPosts, privileges) {
|
||||
next(null, topicPosts);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -556,14 +556,15 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('api:topic.loadMore', function(data) {
|
||||
socket.on('api:topic.loadMore', function(data, callback) {
|
||||
var start = data.after,
|
||||
end = start + 10;
|
||||
|
||||
|
||||
topics.getTopicPosts(data.tid, start, end, uid, function(posts) {
|
||||
io.sockets.in('topic_' + data.tid).emit('event:new_post', {
|
||||
posts: posts
|
||||
});
|
||||
//io.sockets.in('topic_' + data.tid).emit('event:new_post', {
|
||||
// posts: posts
|
||||
//});
|
||||
callback({posts:posts});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user