mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Fix small bug introduced in 20eae33
Duplicate comments were being retrieved from Reddit under certain uncommon circumstances, this also caused the comment counts to be off
This commit is contained in:
parent
157fd7104f
commit
47b4d913bd
1 changed files with 6 additions and 1 deletions
|
|
@ -54,14 +54,19 @@ class Thread extends React.Component {
|
|||
console.log(`Pushshift: ${pushshiftComments.length} comments`)
|
||||
const pushshiftCommentLookup = new Map(pushshiftComments.map(c => [c.id, c]))
|
||||
const ids = []
|
||||
const missingIds = new Set()
|
||||
|
||||
// Extract ids from pushshift response
|
||||
pushshiftComments.forEach(comment => {
|
||||
ids.push(comment.id)
|
||||
if (comment.parent_id != threadID && !pushshiftCommentLookup.has(comment.parent_id)) {
|
||||
if (comment.parent_id != threadID &&
|
||||
!pushshiftCommentLookup.has(comment.parent_id) &&
|
||||
!missingIds.has(comment.parent_id)) {
|
||||
ids.push(comment.parent_id)
|
||||
missingIds.add(comment.parent_id)
|
||||
}
|
||||
});
|
||||
missingIds.clear()
|
||||
|
||||
// Get all the comments from reddit
|
||||
this.props.global.setLoading('Comparing comments to Reddit API...')
|
||||
|
|
|
|||
Loading…
Reference in a new issue