fix: #7788, fix on topic move and new post

This commit is contained in:
Baris Usakli
2019-07-26 14:23:10 -04:00
parent 053ff510bb
commit 8bf40d04c9
3 changed files with 9 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ module.exports = function (Categories) {
};
Categories.updateRecentTidForCid = async function (cid) {
let recentTid;
let postData;
let topicData;
let index = 0;
do {
@@ -46,16 +46,16 @@ module.exports = function (Categories) {
if (!pids.length) {
return;
}
recentTid = await posts.getPostField(pids[0], 'tid');
if (!recentTid) {
return;
postData = await posts.getPostFields(pids[0], ['tid', 'deleted']);
if (postData && postData.tid && !postData.deleted) {
topicData = await topics.getTopicData(postData.tid);
}
topicData = await topics.getTopicData(recentTid);
index += 1;
} while (!topicData || topicData.deleted);
if (recentTid) {
await Categories.updateRecentTid(cid, recentTid);
if (postData && postData.tid) {
await Categories.updateRecentTid(cid, postData.tid);
}
};