mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
getPidPage fix, pids are strings
This commit is contained in:
42
src/posts.js
42
src/posts.js
@@ -474,31 +474,31 @@ var db = require('./database'),
|
||||
}
|
||||
|
||||
Posts.getPidPage = function(pid, uid, callback) {
|
||||
Posts.getPostField(pid, 'tid', function(err, tid) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
if(!pid) {
|
||||
return callback(new Error('invalid-pid'));
|
||||
}
|
||||
|
||||
topics.getPids(tid, function(err, pids) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var index = pids.indexOf(pid);
|
||||
var index = 0;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Posts.getPostField(pid, 'tid', next);
|
||||
},
|
||||
function(tid, next) {
|
||||
topics.getPids(tid, next);
|
||||
},
|
||||
function(pids, next) {
|
||||
index = pids.indexOf(pid.toString());
|
||||
if(index === -1) {
|
||||
return callback(new Error('pid not found'));
|
||||
return next(new Error('pid not found'));
|
||||
}
|
||||
|
||||
user.getSettings(uid, function(err, settings) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
user.getSettings(uid, next);
|
||||
},
|
||||
function(settings, next) {
|
||||
next(null, Math.ceil((index + 1) / settings.postsPerPage));
|
||||
}
|
||||
|
||||
var page = Math.ceil((index + 1) / settings.postsPerPage);
|
||||
callback(null, page);
|
||||
});
|
||||
});
|
||||
});
|
||||
], callback);
|
||||
};
|
||||
|
||||
Posts.getPidIndex = function(pid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user