Fix loading screen not appearing when changing query in browser screen
Fixes #1438 Closes #1441 (cherry picked from commit 9aef08c333397caa4b897514cf76966592d3849c) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SourceSearchScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt
This commit is contained in:
parent
b98dfd65b5
commit
ce96b53f10
@ -8,7 +8,6 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
@ -24,6 +23,8 @@ import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.launch
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.core.common.Constants
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
@ -82,7 +83,7 @@ data class SourceSearchScreen(
|
||||
}
|
||||
BrowseSourceContent(
|
||||
source = screenModel.source,
|
||||
mangaList = screenModel.mangaPagerFlow.collectAsLazyPagingItems(),
|
||||
mangaList = screenModel.mangaPagerFlowFlow.collectAsLazyPagingItems(),
|
||||
columns = screenModel.getColumnsPreference(LocalConfiguration.current.orientation),
|
||||
// SY -->
|
||||
ehentaiBrowseDisplayMode = screenModel.ehentaiBrowseDisplayMode,
|
||||
|
@ -32,7 +32,6 @@ import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
@ -61,6 +60,7 @@ import exh.ui.ifSourcesLoaded
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.core.common.Constants
|
||||
import tachiyomi.core.common.util.lang.launchIO
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
@ -242,7 +242,7 @@ data class BrowseSourceScreen(
|
||||
) { paddingValues ->
|
||||
BrowseSourceContent(
|
||||
source = screenModel.source,
|
||||
mangaList = screenModel.mangaPagerFlow.collectAsLazyPagingItems(),
|
||||
mangaList = screenModel.mangaPagerFlowFlow.collectAsLazyPagingItems(),
|
||||
columns = screenModel.getColumnsPreference(LocalConfiguration.current.orientation),
|
||||
// SY -->
|
||||
ehentaiBrowseDisplayMode = screenModel.ehentaiBrowseDisplayMode,
|
||||
|
@ -185,9 +185,9 @@ open class BrowseSourceScreenModel(
|
||||
* Flow of Pager flow tied to [State.listing]
|
||||
*/
|
||||
private val hideInLibraryItems = sourcePreferences.hideInLibraryItems().get()
|
||||
val mangaPagerFlow = state.map { it.listing }
|
||||
val mangaPagerFlowFlow = state.map { it.listing }
|
||||
.distinctUntilChanged()
|
||||
.flatMapLatest { listing ->
|
||||
.map { listing ->
|
||||
Pager(PagingConfig(pageSize = 25)) {
|
||||
// SY -->
|
||||
createSourcePagingSource(listing.query ?: "", listing.filters)
|
||||
@ -204,8 +204,9 @@ open class BrowseSourceScreenModel(
|
||||
}
|
||||
.filter { !hideInLibraryItems || !it.value.first.favorite }
|
||||
}
|
||||
}
|
||||
.cachedIn(ioCoroutineScope)
|
||||
}
|
||||
.stateIn(ioCoroutineScope, SharingStarted.Lazily, emptyFlow())
|
||||
|
||||
fun getColumnsPreference(orientation: Int): GridCells {
|
||||
val isLandscape = orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
|
@ -10,7 +10,6 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
@ -25,6 +24,7 @@ import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreenModel
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryScreen
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.core.common.util.lang.launchIO
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
import tachiyomi.i18n.sy.SYMR
|
||||
@ -67,7 +67,7 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
|
||||
) { paddingValues ->
|
||||
BrowseSourceContent(
|
||||
source = screenModel.source,
|
||||
mangaList = screenModel.mangaPagerFlow.collectAsLazyPagingItems(),
|
||||
mangaList = screenModel.mangaPagerFlowFlow.collectAsLazyPagingItems(),
|
||||
columns = screenModel.getColumnsPreference(LocalConfiguration.current.orientation),
|
||||
// SY -->
|
||||
ehentaiBrowseDisplayMode = screenModel.ehentaiBrowseDisplayMode,
|
||||
|
@ -5,7 +5,6 @@ import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
@ -14,6 +13,7 @@ import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.i18n.sy.SYMR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
@ -52,7 +52,7 @@ class MangaDexSimilarScreen(val mangaId: Long, val sourceId: Long) : Screen() {
|
||||
) { paddingValues ->
|
||||
BrowseSourceContent(
|
||||
source = screenModel.source,
|
||||
mangaList = screenModel.mangaPagerFlow.collectAsLazyPagingItems(),
|
||||
mangaList = screenModel.mangaPagerFlowFlow.collectAsLazyPagingItems(),
|
||||
columns = screenModel.getColumnsPreference(LocalConfiguration.current.orientation),
|
||||
// SY -->
|
||||
ehentaiBrowseDisplayMode = false,
|
||||
|
@ -5,7 +5,6 @@ import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
@ -15,6 +14,7 @@ import eu.kanade.presentation.browse.components.BrowseSourceSimpleToolbar
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.ui.browse.source.SourcesScreen
|
||||
import exh.ui.ifSourcesLoaded
|
||||
import mihon.presentation.core.util.collectAsLazyPagingItems
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
@ -51,7 +51,7 @@ class RecommendsScreen(val mangaId: Long, val sourceId: Long) : Screen() {
|
||||
) { paddingValues ->
|
||||
BrowseSourceContent(
|
||||
source = screenModel.source,
|
||||
mangaList = screenModel.mangaPagerFlow.collectAsLazyPagingItems(),
|
||||
mangaList = screenModel.mangaPagerFlowFlow.collectAsLazyPagingItems(),
|
||||
columns = screenModel.getColumnsPreference(LocalConfiguration.current.orientation),
|
||||
// SY -->
|
||||
ehentaiBrowseDisplayMode = false,
|
||||
|
@ -45,5 +45,7 @@ dependencies {
|
||||
implementation(compose.ui.tooling.preview)
|
||||
implementation(compose.ui.util)
|
||||
|
||||
implementation(androidx.paging.runtime)
|
||||
implementation(androidx.paging.compose)
|
||||
implementation(kotlinx.immutables)
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package mihon.presentation.core.util
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.paging.PagingData
|
||||
import androidx.paging.compose.LazyPagingItems
|
||||
import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
@Composable
|
||||
fun <T: Any> StateFlow<Flow<PagingData<T>>>.collectAsLazyPagingItems(): LazyPagingItems<T> {
|
||||
val flow by collectAsState()
|
||||
return flow.collectAsLazyPagingItems()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user