Fix filtering pages by branches

This commit is contained in:
Koitharu
2024-02-18 09:14:49 +02:00
parent abc3e45907
commit 0c25c61858

View File

@@ -13,7 +13,9 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import coil.ImageLoader import coil.ImageLoader
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.exceptions.resolve.SnackbarErrorObserver import org.koitharu.kotatsu.core.exceptions.resolve.SnackbarErrorObserver
import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.prefs.AppSettings
@@ -65,11 +67,12 @@ class PagesFragment :
detailsViewModel.selectedBranch, detailsViewModel.selectedBranch,
) { details, history, branch -> ) { details, history, branch ->
if (details != null && (details.isLoaded || details.chapters.isNotEmpty())) { if (details != null && (details.isLoaded || details.chapters.isNotEmpty())) {
PagesViewModel.State(details, history, branch) PagesViewModel.State(details.filterChapters(branch), history, branch)
} else { } else {
null null
} }
}.observe(this, viewModel::updateState) }.flowOn(Dispatchers.Default)
.observe(this, viewModel::updateState)
} }
override fun onCreateViewBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentPagesBinding { override fun onCreateViewBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentPagesBinding {