getPidPage fix, pids are strings

v1.18.x
Baris Soner Usakli 11 years ago
parent a8c7b32a04
commit 60905b2e21

@ -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) {

Loading…
Cancel
Save