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