mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:21:49 +01:00
GlobalSearchScreen: Skip result screen when using search intent (#9299)
This commit is contained in:
parent
b7cd7b8b4e
commit
c1e23ec18e
@ -1,8 +1,12 @@
|
|||||||
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
|
package eu.kanade.tachiyomi.ui.browse.source.globalsearch
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
@ -10,10 +14,11 @@ import eu.kanade.presentation.browse.GlobalSearchScreen
|
|||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
|
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||||
|
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||||
|
|
||||||
class GlobalSearchScreen(
|
class GlobalSearchScreen(
|
||||||
val searchQuery: String = "",
|
val searchQuery: String = "",
|
||||||
val extensionFilter: String = "",
|
private val extensionFilter: String = "",
|
||||||
) : Screen() {
|
) : Screen() {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -27,7 +32,29 @@ class GlobalSearchScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
val state by screenModel.state.collectAsState()
|
val state by screenModel.state.collectAsState()
|
||||||
|
var showSingleLoadingScreen by remember {
|
||||||
|
mutableStateOf(searchQuery.isNotEmpty() && extensionFilter.isNotEmpty() && state.total == 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showSingleLoadingScreen) {
|
||||||
|
LoadingScreen()
|
||||||
|
|
||||||
|
LaunchedEffect(state.items) {
|
||||||
|
when (val result = state.items.values.singleOrNull()) {
|
||||||
|
SearchItemResult.Loading -> return@LaunchedEffect
|
||||||
|
is SearchItemResult.Success -> {
|
||||||
|
val manga = result.result.singleOrNull()
|
||||||
|
if (manga != null) {
|
||||||
|
navigator.replace(MangaScreen(manga.id, true))
|
||||||
|
} else {
|
||||||
|
// Backoff to result screen
|
||||||
|
showSingleLoadingScreen = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> showSingleLoadingScreen = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
GlobalSearchScreen(
|
GlobalSearchScreen(
|
||||||
state = state,
|
state = state,
|
||||||
navigateUp = navigator::pop,
|
navigateUp = navigator::pop,
|
||||||
@ -45,3 +72,4 @@ class GlobalSearchScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user