mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 14:49:17 +01:00
Fix filter search not triggering when clicking genre from Manga details (#8156)
This commit is contained in:
parent
7be6863910
commit
dcd5541e96
@ -92,7 +92,7 @@ fun BrowseSourceScreen(
|
||||
navigateUp = navigateUp,
|
||||
onWebViewClick = onWebViewClick,
|
||||
onHelpClick = onHelpClick,
|
||||
onSearch = { presenter.search() },
|
||||
onSearch = { presenter.search(it) },
|
||||
)
|
||||
|
||||
Row(
|
||||
@ -104,7 +104,7 @@ fun BrowseSourceScreen(
|
||||
FilterChip(
|
||||
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Popular,
|
||||
onClick = {
|
||||
presenter.resetFilter()
|
||||
presenter.reset()
|
||||
presenter.search(GetRemoteManga.QUERY_POPULAR)
|
||||
},
|
||||
leadingIcon = {
|
||||
@ -123,7 +123,7 @@ fun BrowseSourceScreen(
|
||||
FilterChip(
|
||||
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Latest,
|
||||
onClick = {
|
||||
presenter.resetFilter()
|
||||
presenter.reset()
|
||||
presenter.search(GetRemoteManga.QUERY_LATEST)
|
||||
},
|
||||
leadingIcon = {
|
||||
|
@ -44,7 +44,7 @@ fun SourceSearchScreen(
|
||||
placeholderText = stringResource(R.string.action_search_hint),
|
||||
navigateUp = navigateUp,
|
||||
onResetClick = { presenter.searchQuery = "" },
|
||||
onSearchClick = { presenter.search() },
|
||||
onSearchClick = { presenter.search(it) },
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ fun BrowseSourceToolbar(
|
||||
navigateUp: () -> Unit,
|
||||
onWebViewClick: () -> Unit,
|
||||
onHelpClick: () -> Unit,
|
||||
onSearch: () -> Unit,
|
||||
onSearch: (String) -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior? = null,
|
||||
) {
|
||||
if (state.searchQuery == null) {
|
||||
@ -56,13 +56,17 @@ fun BrowseSourceToolbar(
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
} else {
|
||||
val cancelSearch = { state.searchQuery = null }
|
||||
BrowseSourceSearchToolbar(
|
||||
searchQuery = state.searchQuery!!,
|
||||
onSearchQueryChanged = { state.searchQuery = it },
|
||||
placeholderText = stringResource(R.string.action_search_hint),
|
||||
navigateUp = { state.searchQuery = null },
|
||||
navigateUp = cancelSearch,
|
||||
onResetClick = { state.searchQuery = "" },
|
||||
onSearchClick = onSearch,
|
||||
onSearchClick = {
|
||||
onSearch(it)
|
||||
cancelSearch()
|
||||
},
|
||||
scrollBehavior = scrollBehavior,
|
||||
)
|
||||
}
|
||||
@ -165,7 +169,7 @@ fun BrowseSourceSearchToolbar(
|
||||
placeholderText: String?,
|
||||
navigateUp: () -> Unit,
|
||||
onResetClick: () -> Unit,
|
||||
onSearchClick: () -> Unit,
|
||||
onSearchClick: (String) -> Unit,
|
||||
scrollBehavior: TopAppBarScrollBehavior?,
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
@ -178,7 +182,7 @@ fun BrowseSourceSearchToolbar(
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions(
|
||||
onSearch = {
|
||||
onSearchClick()
|
||||
onSearchClick(searchQuery)
|
||||
focusManager.clearFocus()
|
||||
keyboardController?.hide()
|
||||
},
|
||||
|
@ -119,7 +119,10 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
private fun navigateUp() {
|
||||
when {
|
||||
presenter.searchQuery != null -> presenter.searchQuery = null
|
||||
presenter.isUserQuery -> presenter.search()
|
||||
presenter.isUserQuery -> {
|
||||
val (_, filters) = presenter.currentFilter as BrowseSourcePresenter.Filter.UserInput
|
||||
presenter.search(query = "", filters = filters)
|
||||
}
|
||||
else -> router.popCurrentController()
|
||||
}
|
||||
}
|
||||
@ -132,10 +135,10 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
filterSheet = SourceFilterSheet(
|
||||
activity!!,
|
||||
onFilterClicked = {
|
||||
presenter.setSourceFilter(presenter.filters)
|
||||
presenter.search(filters = presenter.filters)
|
||||
},
|
||||
onResetClicked = {
|
||||
presenter.resetFilter()
|
||||
presenter.reset()
|
||||
filterSheet?.setFilters(presenter.filterItems)
|
||||
},
|
||||
)
|
||||
@ -190,10 +193,9 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
}
|
||||
|
||||
if (genreExists) {
|
||||
filterSheet?.setFilters(presenter.filterItems)
|
||||
filterSheet?.setFilters(defaultFilters.toItems())
|
||||
|
||||
presenter.searchQuery = ""
|
||||
presenter.setFilter(defaultFilters)
|
||||
presenter.search(filters = defaultFilters)
|
||||
} else {
|
||||
searchWithQuery(genreName)
|
||||
}
|
||||
|
@ -155,22 +155,25 @@ open class BrowseSourcePresenter(
|
||||
}
|
||||
}
|
||||
|
||||
fun setFilter(filters: FilterList) {
|
||||
state.filters = filters
|
||||
}
|
||||
|
||||
fun resetFilter() {
|
||||
fun reset() {
|
||||
state.filters = source!!.getFilterList()
|
||||
if (currentFilter !is Filter.UserInput) return
|
||||
state.currentFilter = (currentFilter as Filter.UserInput).copy(filters = state.filters)
|
||||
}
|
||||
|
||||
fun search(query: String? = null) {
|
||||
var new = Filter.valueOf(query ?: searchQuery ?: "")
|
||||
if (new is Filter.UserInput && currentFilter is Filter.UserInput) {
|
||||
new = new.copy(filters = currentFilter.filters)
|
||||
fun search(query: String? = null, filters: FilterList? = null) {
|
||||
Filter.valueOf(query ?: "").let {
|
||||
if (it !is Filter.UserInput) {
|
||||
state.currentFilter = it
|
||||
return
|
||||
}
|
||||
}
|
||||
state.currentFilter = new
|
||||
|
||||
val input: Filter.UserInput = if (currentFilter is Filter.UserInput) currentFilter as Filter.UserInput else Filter.UserInput()
|
||||
state.currentFilter = input.copy(
|
||||
query = query ?: input.query,
|
||||
filters = filters ?: input.filters,
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreate(savedState: Bundle?) {
|
||||
@ -305,18 +308,6 @@ open class BrowseSourcePresenter(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filter states for the current source.
|
||||
*
|
||||
* @param filters a list of active filters.
|
||||
*/
|
||||
fun setSourceFilter(filters: FilterList) {
|
||||
state.currentFilter = when (val filter = currentFilter) {
|
||||
Filter.Latest, Filter.Popular -> Filter.UserInput(filters = filters)
|
||||
is Filter.UserInput -> filter.copy(filters = filters)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user categories.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user