Fix reader race conditions and loading page height

This commit is contained in:
Syer10
2022-11-15 21:44:33 -05:00
parent 25d3a5b471
commit d8100ee309
3 changed files with 10 additions and 6 deletions

View File

@@ -446,7 +446,9 @@ fun ReaderLayout(
progress: (Int) -> Unit,
updateLastPageReadOffset: (Int) -> Unit
) {
val loadingModifier = Modifier.fillMaxWidth().aspectRatio(mangaAspectRatio)
val loadingModifier = Modifier.widthIn(max = 700.dp)
.fillMaxWidth()
.aspectRatio(mangaAspectRatio)
val readerModifier = Modifier
.navigationClickable(
navigation = navigationViewer,
@@ -524,11 +526,11 @@ fun ReaderImage(
retry: (Int) -> Unit
) {
Crossfade(drawableHolder to status) { (drawableHolder, status) ->
val drawableCallback = drawableHolder.item
val decodeState = produceState<ReaderPage.ImageDecodeState?>(null, drawableCallback) {
if (drawableCallback != null) {
val decodeState = produceState<ReaderPage.ImageDecodeState?>(null, drawableHolder) {
val callback = drawableHolder.item
if (callback != null) {
withIOContext {
value = drawableCallback()
value = callback()
}
}
}
@@ -543,7 +545,7 @@ fun ReaderImage(
)
} else {
LoadingScreen(
status == ReaderPage.Status.QUEUE,
status == ReaderPage.Status.QUEUE || status == ReaderPage.Status.WORKING,
loadingModifier,
progress,
error ?: when (decode) {

View File

@@ -80,6 +80,7 @@ class TachideskPageLoader(
val page = priorityPage.page
log.debug { "Loading page ${page.index}" }
if (page.status.value == ReaderPage.Status.QUEUE) {
page.status.value = ReaderPage.Status.WORKING
getChapterPage.asFlow(chapter.chapter, page.index) {
onDownload { bytesSentTotal, contentLength ->
page.progress.value = (bytesSentTotal.toFloat() / contentLength).coerceAtMost(1.0F)

View File

@@ -22,6 +22,7 @@ data class ReaderPage(
) {
enum class Status {
QUEUE,
WORKING,
READY,
ERROR
}