fix: handle start=0 stop=0 for topics.getTopicPosts

add more tests
This commit is contained in:
Barış Soner Uşaklı
2021-12-06 16:36:30 -05:00
parent 621c142f8e
commit 906dc5675e
4 changed files with 42 additions and 5 deletions

View File

@@ -30,9 +30,7 @@ module.exports = function (SocketTopics) {
parseInt(data.count, 10) || meta.config.postsPerPage || 20
));
if (data.direction === 1) {
start += 1;
} else if (data.direction === -1) {
if (data.direction === -1) {
start -= infScrollPostsPerPage;
}

View File

@@ -39,7 +39,10 @@ module.exports = function (Topics) {
repliesStart -= 1;
}
}
const pids = await posts.getPidsFromSet(set, repliesStart, repliesStop, reverse);
let pids = [];
if (start !== 0 || stop !== 0) {
pids = await posts.getPidsFromSet(set, repliesStart, repliesStop, reverse);
}
if (!pids.length && !topicOrTid.mainPid) {
return [];
}