Skip to content

Commit

Permalink
Fix bug in posts stream
Browse files Browse the repository at this point in the history
This commits fixes an issue where posts would still appear
even if they had already been fetched when using the DiscardInitial
option.
  • Loading branch information
Sadzeih committed Jun 28, 2022
1 parent 63ffc3f commit ba4f3e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions reddit/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ func (s *StreamService) Posts(subreddit string, opts ...StreamOpt) (<-chan *Post
}
ids.Add(id)

// skip this post because we are discarding initial fetch of posts
if streamConfig.DiscardInitial {
streamConfig.DiscardInitial = false
break
continue
}

postsCh <- post
}

// setting discard initial to false, since we the loop has run once already
streamConfig.DiscardInitial = false

if !infinite && n >= streamConfig.MaxRequests {
break
}
Expand Down

0 comments on commit ba4f3e3

Please sign in to comment.