Fix hide entries in library setting causing browse to not load
Fixes #9924 (cherry picked from commit d4290f6f596dcafbe354eec51875680eb854d179) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt
This commit is contained in:
parent
326cd14db4
commit
be8df884d5
@ -9,6 +9,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.paging.Pager
|
import androidx.paging.Pager
|
||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
|
import androidx.paging.filter
|
||||||
import androidx.paging.map
|
import androidx.paging.map
|
||||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||||
import cafe.adriel.voyager.core.model.coroutineScope
|
import cafe.adriel.voyager.core.model.coroutineScope
|
||||||
@ -39,7 +40,6 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.emptyFlow
|
import kotlinx.coroutines.flow.emptyFlow
|
||||||
import kotlinx.coroutines.flow.filter
|
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
import kotlinx.coroutines.flow.filterNotNull
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
import kotlinx.coroutines.flow.flatMapLatest
|
import kotlinx.coroutines.flow.flatMapLatest
|
||||||
@ -191,30 +191,25 @@ open class BrowseSourceScreenModel(
|
|||||||
/**
|
/**
|
||||||
* Flow of Pager flow tied to [State.listing]
|
* Flow of Pager flow tied to [State.listing]
|
||||||
*/
|
*/
|
||||||
|
private val hideInLibraryItems = sourcePreferences.hideInLibraryItems().get()
|
||||||
val mangaPagerFlowFlow = state.map { it.listing }
|
val mangaPagerFlowFlow = state.map { it.listing }
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.map { listing ->
|
.map { listing ->
|
||||||
Pager(
|
Pager(PagingConfig(pageSize = 25)) {
|
||||||
PagingConfig(pageSize = 25),
|
|
||||||
) {
|
|
||||||
// SY -->
|
// SY -->
|
||||||
createSourcePagingSource(listing.query ?: "", listing.filters)
|
createSourcePagingSource(listing.query ?: "", listing.filters)
|
||||||
// SY <--
|
// SY <--
|
||||||
}.flow.map { pagingData ->
|
}.flow.map { pagingData ->
|
||||||
pagingData.map { (it, metadata) ->
|
pagingData.map { (it, metadata) ->
|
||||||
networkToLocalManga.await(it.toDomainManga(sourceId))
|
networkToLocalManga.await(it.toDomainManga(sourceId))
|
||||||
.let { localManga ->
|
.let { localManga -> getManga.subscribe(localManga.url, localManga.source) }
|
||||||
getManga.subscribe(localManga.url, localManga.source)
|
|
||||||
}
|
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.filter { localManga ->
|
|
||||||
!sourcePreferences.hideInLibraryItems().get() || !localManga.favorite
|
|
||||||
}
|
|
||||||
// SY -->
|
// SY -->
|
||||||
.combineMetadata(metadata)
|
.combineMetadata(metadata)
|
||||||
// SY <--
|
// SY <--
|
||||||
.stateIn(ioCoroutineScope)
|
.stateIn(ioCoroutineScope)
|
||||||
}
|
}
|
||||||
|
.filter { !hideInLibraryItems || !it.value.favorite }
|
||||||
}
|
}
|
||||||
.cachedIn(ioCoroutineScope)
|
.cachedIn(ioCoroutineScope)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user