mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Fix bug w/0-comment posts introduced in 07c72a2
This commit is contained in:
parent
d6a55ee31c
commit
fb327e7b94
1 changed files with 6 additions and 4 deletions
|
|
@ -68,7 +68,7 @@ export const getPost = async threadID => {
|
|||
}
|
||||
|
||||
export const getComments = async (allComments, threadID, maxComments, after) => {
|
||||
let chunks = Math.ceil(maxComments / chunkSize), comments
|
||||
let chunks = Math.ceil(maxComments / chunkSize), comments, lastCreatedUtc = 1
|
||||
while (true) {
|
||||
|
||||
let delay = 0
|
||||
|
|
@ -93,11 +93,13 @@ export const getComments = async (allComments, threadID, maxComments, after) =>
|
|||
parent_id: c.parent_id?.substring(3) || threadID,
|
||||
link_id: c.link_id?.substring(3) || threadID
|
||||
}))
|
||||
if (comments.length)
|
||||
lastCreatedUtc = comments[comments.length - 1].created_utc
|
||||
if (comments.length < chunkSize/2)
|
||||
return [ comments[comments.length - 1].created_utc, true ]
|
||||
return [ lastCreatedUtc, true ]
|
||||
if (chunks <= 1)
|
||||
return [ comments[comments.length - 1].created_utc, false ]
|
||||
return [ lastCreatedUtc, false ]
|
||||
chunks--
|
||||
after = Math.max(comments[comments.length - 1].created_utc - 1, after + 1)
|
||||
after = Math.max(lastCreatedUtc - 1, after + 1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue