Closed ezhes closed 6 years ago
Well... I don't have any idea about this issue. I can not find a subreddit which has very few posts (<20).....
https://www.reddit.com/r/TridentLayers/
When I paginate I get the first 19 posts back again
Thank you. Ooops....
I confirm /r/TridentLayers/. But, my sample application works well.
I think you can reproduce my result by following procedure.
FrontViewController.swift
at line 366.
cellar = SubredditCellar(subreddit: "TridentLayers", width: self.view.frame.size.width, fontSize: 18)
https://github.com/sonsongithub/reddift/
.Could you show me what I'm doing wrong here?
self.paginator
is not nil since it's bang expanded.
try self.session!.getList(self.paginator!, subreddit: self.subreddit, sort: LinkSortType.hot, timeFilterWithin: TimeFilterWithin.day) {...
Then later on successful retrieval of the posts I call
self.paginator = listing.paginator
to move the paginator up to the new state returned after reading. Now that I think about it, is this a problem? Is the getList
a mutator for the paginator? That might explain why it works only sort of when I reset it.
I only have my code in front of me, can't build since I'm away from my main machine, but I'm likely misusing the paginator.
I coded this code a couple of years. I'm so sorry if I suggest something wrong.
Do you check Paginator.after
is vacant?
I remembered that you should check value of paginator.isVacant
before you call getList
.
paginator.isVacant
returns false
if there are not any contents after the current paginator.
I don't have any more suggestions about this issue.....
Thank you.
Check out SubredditCellar.swift
.
/// Do nothing in case paginator is vacant and load subreddit to append contents.
if self.paginator.isVacant && !atTheBeginning { return }
/// Do nothing in case this controller is loading.
if loading { return }
Thanks! That fixes the more obvious one of my issues. I do still, for whatever reason, sometimes get a few duplicate posts back from my paginator. These posts always come back with either a different comment count or upvote comment though I assume you are checking for duplicates based on the post ID?
When I paginate I call
self.links+=listing.children.flatMap({$0 as? Link}) as [Thing]
which works correctly 95% of the time. I've confirmed that it's not an issue with my tableview drawing the same link twice. I'm wondering if I should just through a hash table in front of my adding code to filter out duplicate post IDs? I figured that's what the paginator did anyways.
It also seems like it gets worse with duplicates the longer it's been since the paginator was initially created. Like if I load the first page, wait a few minutes, and then paginate I get more duplicates than if I were to immediately paginate. No proof to back this up, just been using my app as my daily driver and I noticed it.
Please check my sample code.
SubredditCellar.swift
does not duplicate any Link
s.
Paginator worked last year but it's no longer always working correctly, often returning a mix of new content and old content. This means Paginator is working but it's not filtering out already seen posts (like RES on the desktop has to do). Am I doing something wrong or would you like me to quickly throw a pull together?
This is especially obvious in a subreddit which has very few posts (<20) because once you paginate you get the exact same posts in the same order again.