mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
teaser fixes
if a post is deleted/restored update the teaser to the latest undeleted pid, if all posts are deleted it will be set to null
This commit is contained in:
@@ -101,11 +101,12 @@ module.exports = function(Topics) {
|
||||
};
|
||||
|
||||
Topics.updateTeaser = function(tid, callback) {
|
||||
db.getSortedSetRevRange('tid:' + tid + ':posts', 0, 0, function(err, pids) {
|
||||
Topics.getLatestUndeletedPid(tid, function(err, pid) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var pid = Array.isArray(pids) && pids.length ? pids[0] : null;
|
||||
|
||||
pid = pid || null;
|
||||
Topics.setTopicField(tid, 'teaserPid', pid, callback);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user