when a post is moved update recent topics order

v1.18.x
barisusakli 10 years ago
parent b75dfa9f6e
commit f6be4efe8b

@ -94,7 +94,7 @@ module.exports = function(Topics) {
}
if (parseInt(post.tid, 10) === parseInt(tid, 10)) {
return next(new Error('[[error:cant-move-to-same-topic]]'))
return next(new Error('[[error:cant-move-to-same-topic]]'));
}
postData = post;
@ -117,6 +117,12 @@ module.exports = function(Topics) {
Topics.addPostToTopic(tid, pid, postData.timestamp, postData.votes, next);
}
], next);
},
function(results, next) {
async.parallel([
async.apply(updateRecentTopic, tid),
async.apply(updateRecentTopic, postData.tid)
], next);
}
], function(err) {
if (err) {
@ -126,4 +132,23 @@ module.exports = function(Topics) {
callback();
});
};
function updateRecentTopic(tid, callback) {
async.waterfall([
function(next) {
Topics.getLatestUndeletedPid(tid, next);
},
function(pid, next) {
if (!pid) {
return callback();
}
posts.getPostField(pid, 'timestamp', next);
},
function(timestamp, next) {
Topics.updateTimestamp(tid, timestamp, next);
}
], callback);
}
};

Loading…
Cancel
Save