Everything sort-of works, I am using StartAfter() with a document reference in order to paginate, however the query creates an infinite loop as when the final document that should be fetched by the query is fed back into the StartAfter() method, the pointer on the query goes back to the first document from the query - this makes all of the same data load again and again.
EG using a collection with 10 documents using LimitTo(6):
First run loads 1, 2, 3, 4, 5, 6 and places '6' in the LastPost variable - Good
Second run using StartAfter(6) loads 7, 8, 9, 10 - Good
Third run using StartAfter(10) loads 1, 2, 3, 4, 5, 6 - Completely wrong
Third run should not do this and should load nothing and return empty because it has reached the end of the data.
Everything sort-of works, I am using StartAfter() with a document reference in order to paginate, however the query creates an infinite loop as when the final document that should be fetched by the query is fed back into the StartAfter() method, the pointer on the query goes back to the first document from the query - this makes all of the same data load again and again.
EG using a collection with 10 documents using LimitTo(6):
First run loads 1, 2, 3, 4, 5, 6 and places '6' in the LastPost variable - Good Second run using StartAfter(6) loads 7, 8, 9, 10 - Good Third run using StartAfter(10) loads 1, 2, 3, 4, 5, 6 - Completely wrong
Third run should not do this and should load nothing and return empty because it has reached the end of the data.