fix: requests take too long

This commit is contained in:
Tobi Saputra 2025-02-07 21:06:21 +07:00
parent 80cbe6d5e9
commit b9095993bd
2 changed files with 7 additions and 3 deletions

View File

@ -105,7 +105,7 @@ const parseComments = async (
const result = await requestComments(id, cursor, proxy)
// Check if the result has more comments
// Check if the result has more comments &
if (result.has_more === 0) hasMore = false
result.comments?.forEach((v: any) => {
@ -162,6 +162,7 @@ const parseComments = async (
if (commentLimit) {
let loopCount = Math.floor(commentLimit / 50)
if (counter >= loopCount) hasMore = false
break
}
hasMore = result.has_more === 1
@ -169,8 +170,10 @@ const parseComments = async (
counter++
}
const response =
total > commentLimit ? comments.slice(0, commentLimit) : comments
return {
total: total,
comments: commentLimit ? comments.slice(0, commentLimit) : comments
total: response.length,
comments: response
}
}

View File

@ -247,6 +247,7 @@ const parsePosts = async (
if (postLimit !== 0) {
let loopCount = Math.floor(postLimit / 30)
if (counter >= loopCount) hasMore = false
break
}
hasMore = result.hasMore