mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-12 12:08:56 +01:00
Fix derivedStateOf errors (#8008)
This commit is contained in:
@@ -43,9 +43,7 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibraryDisplayMode
|
||||
import eu.kanade.tachiyomi.ui.library.setting.LibrarySort
|
||||
import eu.kanade.tachiyomi.ui.library.setting.display
|
||||
import eu.kanade.tachiyomi.ui.library.setting.sort
|
||||
import eu.kanade.tachiyomi.util.lang.combineLatest
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
@@ -642,13 +640,12 @@ class LibraryPresenter(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getMangaForCategory(page: Int): androidx.compose.runtime.State<List<LibraryItem>> {
|
||||
val categoryId = remember(categories) {
|
||||
categories.getOrNull(page)?.id ?: -1
|
||||
fun getMangaForCategory(page: Int): List<LibraryItem> {
|
||||
val unfiltered = remember(categories, loadedManga) {
|
||||
val categoryId = categories.getOrNull(page)?.id ?: -1
|
||||
loadedManga[categoryId] ?: emptyList()
|
||||
}
|
||||
val unfiltered = loadedManga[categoryId] ?: emptyList()
|
||||
|
||||
return derivedStateOf {
|
||||
return remember(unfiltered) {
|
||||
val query = searchQuery
|
||||
if (query.isNullOrBlank().not()) {
|
||||
unfiltered.filter {
|
||||
@@ -660,14 +657,6 @@ class LibraryPresenter(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun getDisplayMode(index: Int): androidx.compose.runtime.State<LibraryDisplayMode> {
|
||||
val category = categories[index]
|
||||
return derivedStateOf {
|
||||
category.display
|
||||
}
|
||||
}
|
||||
|
||||
fun clearSelection() {
|
||||
state.selection = emptyList()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.SnackbarResult
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
@@ -111,13 +110,6 @@ class MangaController : FullComposeController<MangaPresenter> {
|
||||
return
|
||||
}
|
||||
|
||||
val dialog by derivedStateOf {
|
||||
when (val state = state) {
|
||||
MangaScreenState.Loading -> null
|
||||
is MangaScreenState.Success -> state.dialog
|
||||
}
|
||||
}
|
||||
|
||||
val successState = state as MangaScreenState.Success
|
||||
val isHttpSource = remember { successState.source is HttpSource }
|
||||
val scope = rememberCoroutineScope()
|
||||
@@ -152,7 +144,7 @@ class MangaController : FullComposeController<MangaPresenter> {
|
||||
)
|
||||
|
||||
val onDismissRequest = { presenter.dismissDialog() }
|
||||
when (val dialog = dialog) {
|
||||
when (val dialog = (state as? MangaScreenState.Success)?.dialog) {
|
||||
is Dialog.ChangeCategory -> {
|
||||
ChangeCategoryDialog(
|
||||
initialSelection = dialog.initialSelection,
|
||||
|
||||
Reference in New Issue
Block a user