Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on vlemmy.net
lemmydev·Lemmy App Development bySlated

getPosts response duplicate posts

Is anyone else getting an error where duplicate posts are recieved on different pages with the getPosts function in the api? It seems to mostly happen with the subscribed viewtype

View original on vlemmy.net
1

3 replies

feddit.de

That's likely because you are asking the api for a paginated list of posts/comments. When you request page 1 at one point and page 2 at a later time, the list of posts can change inbetween, so posts that were part of page 1 have now been pushed down into page to, so you get them again when loading page 2. The solution is to keep a list of post ids that are already in your list of posts and don't load those again, same with comments.

2
Slatedreply
vlemmy.net

Ah smart. I fixed the issue by sorting out duplicate post ids before displaying my list of posts

1

You reached the end

getPosts response duplicate posts | Spyke