Fix pagination
This commit is contained in:
@@ -16,8 +16,8 @@ android {
|
||||
applicationId 'org.koitharu.kotatsu'
|
||||
minSdk = 21
|
||||
targetSdk = 34
|
||||
versionCode = 590
|
||||
versionName = '6.2.3'
|
||||
versionCode = 591
|
||||
versionName = '6.2.4'
|
||||
generatedDensities = []
|
||||
testInstrumentationRunner "org.koitharu.kotatsu.HiltTestRunner"
|
||||
ksp {
|
||||
@@ -82,7 +82,7 @@ afterEvaluate {
|
||||
}
|
||||
dependencies {
|
||||
//noinspection GradleDependency
|
||||
implementation('com.github.KotatsuApp:kotatsu-parsers:6bf0ae92e4') {
|
||||
implementation('com.github.KotatsuApp:kotatsu-parsers:af1aca8725') {
|
||||
exclude group: 'org.json', module: 'json'
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ dependencies {
|
||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||
implementation 'io.noties.markwon:core:4.6.2'
|
||||
|
||||
implementation 'ch.acra:acra-http:5.11.2'
|
||||
implementation 'ch.acra:acra-dialog:5.11.2'
|
||||
implementation 'ch.acra:acra-http:5.11.3'
|
||||
implementation 'ch.acra:acra-dialog:5.11.3'
|
||||
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.debounce
|
||||
import kotlinx.coroutines.flow.getAndUpdate
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.plus
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.distinctById
|
||||
@@ -134,15 +134,17 @@ open class RemoteListViewModel @Inject constructor(
|
||||
sortOrder = filterState.sortOrder,
|
||||
tags = filterState.tags,
|
||||
)
|
||||
mangaList.update { oldList ->
|
||||
val oldList = mangaList.getAndUpdate { oldList ->
|
||||
if (!append || oldList.isNullOrEmpty()) {
|
||||
list
|
||||
} else {
|
||||
oldList + list
|
||||
}
|
||||
}
|
||||
if (append) {
|
||||
hasNextPage.value = list.isNotEmpty()
|
||||
}.orEmpty()
|
||||
hasNextPage.value = if (append) {
|
||||
list.isNotEmpty()
|
||||
} else {
|
||||
list.size > oldList.size || hasNextPage.value
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
@@ -152,6 +154,7 @@ open class RemoteListViewModel @Inject constructor(
|
||||
if (!mangaList.value.isNullOrEmpty()) {
|
||||
errorEvent.call(e)
|
||||
}
|
||||
hasNextPage.value = false
|
||||
}
|
||||
}.also { loadingJob = it }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user