fix: events for just topic with main post

isekai-main
Barış Soner Uşaklı 3 years ago
parent 89399c0ed5
commit 3d611ab70e

@ -254,9 +254,12 @@ Topics.addNextPostTimestamp = async function (postData, set, reverse) {
}
});
const lastPost = postData[postData.length - 1];
if (lastPost && lastPost.index) {
const data = await db[reverse ? 'getSortedSetRevRangeWithScores' : 'getSortedSetRangeWithScores'](set, lastPost.index, lastPost.index);
lastPost.nextPostTimestamp = data.length ? data[0].score : Date.now();
if (lastPost) {
lastPost.nextPostTimestamp = Date.now();
if (lastPost.index) {
const data = await db[reverse ? 'getSortedSetRevRangeWithScores' : 'getSortedSetRangeWithScores'](set, lastPost.index, lastPost.index);
lastPost.nextPostTimestamp = data.length ? data[0].score : lastPost.nextPostTimestamp;
}
}
};

Loading…
Cancel
Save