Reset page state on page loader restart
This commit is contained in:
1 parent
c60b14998a
commit
1219ff99ff
2 files changed
+15
-2
No files matched your search
@@ -35,6 +35,7 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.loader.PageLoader
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.CombinedCircularProgressIndicator
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import moe.tarsin.kt.unreachable
|
||||
|
||||
@Composable
|
||||
@@ -47,6 +48,11 @@ fun PagerItem(
|
||||
) {
|
||||
LaunchedEffect(Unit) {
|
||||
pageLoader.request(page.index)
|
||||
page.status.drop(1).collect {
|
||||
if (page.status.value == Page.State.QUEUE) {
|
||||
pageLoader.request(page.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
val defaultError = stringResource(id = R.string.decode_image_error)
|
||||
val state by page.status.collectAsState()
|
||||
|
||||
@@ -58,6 +58,7 @@ abstract class PageLoader {
|
||||
|
||||
fun restart() {
|
||||
cache.evictAll()
|
||||
pages.forEach(ReaderPage::reset)
|
||||
}
|
||||
|
||||
abstract val size: Int
|
||||
@@ -111,8 +112,7 @@ abstract class PageLoader {
|
||||
protected abstract fun onCancelRequest(index: Int)
|
||||
|
||||
fun notifyPageWait(index: Int) {
|
||||
pages[index].progress = 0
|
||||
pages[index].status.value = Page.State.QUEUE
|
||||
pages[index].reset()
|
||||
}
|
||||
|
||||
fun notifyPagePercent(index: Int, percent: Float) {
|
||||
@@ -133,3 +133,10 @@ abstract class PageLoader {
|
||||
pages[index].status.value = Page.State.ERROR
|
||||
}
|
||||
}
|
||||
|
||||
private fun ReaderPage.reset() {
|
||||
image = null
|
||||
errorMsg = null
|
||||
progress = 0
|
||||
status.value = Page.State.QUEUE
|
||||
}
|
||||
Reference in new issue
Block a user