diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt index 990da2398..b322e2ee7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreen.kt @@ -84,6 +84,13 @@ data class BrowseSourceScreen( val snackbarHostState = remember { SnackbarHostState() } + val navigateUp: () -> Unit = { + when { + !state.isUserQuery && state.toolbarQuery != null -> screenModel.setToolbarQuery(null) + else -> navigator.pop() + } + } + val onHelpClick = { uriHandler.openUri(LocalSource.HELP_URL) } val onWebViewClick = f@{ @@ -105,7 +112,7 @@ data class BrowseSourceScreen( source = screenModel.source, displayMode = screenModel.displayMode, onDisplayModeChange = { screenModel.displayMode = it }, - navigateUp = navigator::pop, + navigateUp = navigateUp, onWebViewClick = onWebViewClick, onHelpClick = onHelpClick, onSearch = { screenModel.search(it) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt index 5fddb309b..d56f7ec0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt @@ -359,21 +359,20 @@ class BrowseSourceScreenModel( } fun initFilterSheet(context: Context) { - val state = state.value - if (state.filters.isEmpty()) { + if (state.value.filters.isEmpty()) { return } filterSheet = SourceFilterSheet( context = context, - onFilterClicked = { search(filters = state.filters) }, + onFilterClicked = { search(filters = state.value.filters) }, onResetClicked = { reset() - filterSheet?.setFilters(state.filterItems) + filterSheet?.setFilters(state.value.filterItems) }, ) - filterSheet?.setFilters(state.filterItems) + filterSheet?.setFilters(state.value.filterItems) } sealed class Filter(open val query: String?, open val filters: FilterList) { @@ -409,12 +408,8 @@ class BrowseSourceScreenModel( val toolbarQuery: String? = null, val dialog: Dialog? = null, ) { - val filterItems = filters.toItems() - val isUserQuery = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty() - val searchQuery = when (currentFilter) { - is Filter.UserInput -> currentFilter.query - Filter.Latest, Filter.Popular -> null - } + val filterItems get() = filters.toItems() + val isUserQuery get() = currentFilter is Filter.UserInput && !currentFilter.query.isNullOrEmpty() } }