Fix multiple issues regarding sources loading too late

This commit is contained in:
Jobobby04
2024-03-15 19:51:56 -04:00
committed by AntsyLich
parent f087135876
commit a08e03f5cb
12 changed files with 72 additions and 14 deletions
@@ -40,6 +40,7 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.google.android.material.elevation.SurfaceColors
import com.google.android.material.transition.platform.MaterialContainerTransform
import dev.chrisbanes.insetter.applyInsetter
import eu.kanade.core.util.ifSourcesLoaded
import eu.kanade.domain.base.BasePreferences
import eu.kanade.presentation.reader.DisplayRefreshHost
import eu.kanade.presentation.reader.OrientationSelectDialog
@@ -344,6 +345,10 @@ class ReaderActivity : BaseActivity() {
)
}
if (!ifSourcesLoaded()) {
return@setComposeContent
}
val isHttpSource = viewModel.getSource() is HttpSource
val isFullscreen by readerPreferences.fullscreen().collectAsState()
val flashOnPageChange by readerPreferences.flashOnPageChange().collectAsState()
@@ -47,6 +47,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
@@ -264,6 +265,7 @@ class ReaderViewModel @JvmOverloads constructor(
try {
val manga = getManga.await(mangaId)
if (manga != null) {
sourceManager.isInitialized.first { it }
mutableState.update { it.copy(manga = manga) }
if (chapterId == -1L) chapterId = initialChapterId