Closed itssidhere closed 3 years ago
Hi @itssidhere. Can you share some code snippets demonstrating this issue?
I will share the same. But even without it it's evident when a document is changed in the stream(isLive: true).It's included in the new list as well as previous list so adding both list we will have duplicate elements.
My suggestion would be to do something like this
[newList + previousList].toSet().toList()
newList + previous list and not previousList+newList as the duplicate element's latest document is in newList so by toSet() only the newList element will be used.
Disadvantage of this is the order will be lost so the PaginateFirestore should return a builderFunction with the mutated list and not the individual document so that the user can restore the order of the list.
@excogitatr
It's a good suggestion @itssidhere. If it is possible can you make PR with that changes and check if it is working as you intended?
@excogitatr Yes sure, I will make a pr asap.
This is fixed in v1.01+1
, thanks to @garrettApproachableGeek.
Thanks for using the package. Feel free to reopen this if you face any similar issues.
Due to this line in the PaginationCubit file, there are certain cases where the same document is included twice in the list.
emit(PaginationLoaded( documentSnapshots: previousList + newList, hasReachedEnd: newList.isEmpty, ));