Status Update
Comments
du...@google.com <du...@google.com> #2
Thanks for reporting this! I agree! The flag endOfPaginationReached for REFRESH is ignored right now and there's an open bug to fix that
No update yet.
Thanks for reporting this! I agree! The flag endOfPaginationReached for REFRESH is ignored right now and there's an open bug to fix that
Description
Version used: 3.0.0-alpha02
Devices/Android versions reproduced on: all devices
I think you should change behavior for the RemoteMediator when refreshing data.
If in the first (LoadType.REFRESH) request no more data to load we're exposing MediatorResult.Success(endOfPaginationReached = true ), but it will not stop our pagination mediator and it will call the next request with the LoadType (APPEND or PREPEND depend on scrolling direction ).
It happens because we have a pagination option parameter for the prefetch distance and if it's value was not specified as 0 RemoteMediator.load() will call again because it tries to prefetch data.
We can't specify the prefetch distance param as 0 because if we have more data we want to prefetch it.
The point of this issue: if this is the request for LoadType.REFRESH and no more data to load and we called MediatorResult.Success(endOfPaginationReached = true ) we should not call RemoteMediator.load() with next LoadType value and stop pagination.
Now to fix it you should call: LoadType.APPEND -> nextPageNumber() ?: return MediatorResult.Success(endOfPaginationReached = true) to prevent next request