Merge pull request #160 from TouchInstinct/bugfix/paginator-full-state

added paginator full state if itemList < pageSize
This commit is contained in:
RationalEgoism 2020-09-09 14:05:08 +03:00 committed by GitHub
commit 65a6f07bdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -10,7 +10,8 @@ import ru.touchin.roboswag.mvi_arch.marker.ViewState
class Paginator<Item>(
private val errorHandleMod: ErrorHandleMod,
private val loadPage: suspend (Int) -> List<Item>
private val loadPage: suspend (Int) -> List<Item>,
private val pageSize: Int
) : Store<Paginator.Change, Paginator.Effect, Paginator.State>(State.Empty) {
sealed class Change : StateChange {
@ -89,7 +90,7 @@ class Paginator<Item>(
}
}
is State.NewPageProgress<*> -> {
if (items.isEmpty()) {
if (items.size < pageSize) {
State.FullData(currentState.pageCount, currentState.data)
} else {
State.Data(currentState.pageCount + 1, currentState.data + items)