mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 17:19: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,
|
navigateUp = navigateUp,
|
||||||
onWebViewClick = onWebViewClick,
|
onWebViewClick = onWebViewClick,
|
||||||
onHelpClick = onHelpClick,
|
onHelpClick = onHelpClick,
|
||||||
onSearch = { presenter.search() },
|
onSearch = { presenter.search(it) },
|
||||||
)
|
)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@ -104,7 +104,7 @@ fun BrowseSourceScreen(
|
|||||||
FilterChip(
|
FilterChip(
|
||||||
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Popular,
|
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Popular,
|
||||||
onClick = {
|
onClick = {
|
||||||
presenter.resetFilter()
|
presenter.reset()
|
||||||
presenter.search(GetRemoteManga.QUERY_POPULAR)
|
presenter.search(GetRemoteManga.QUERY_POPULAR)
|
||||||
},
|
},
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
@ -123,7 +123,7 @@ fun BrowseSourceScreen(
|
|||||||
FilterChip(
|
FilterChip(
|
||||||
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Latest,
|
selected = presenter.currentFilter == BrowseSourcePresenter.Filter.Latest,
|
||||||
onClick = {
|
onClick = {
|
||||||
presenter.resetFilter()
|
presenter.reset()
|
||||||
presenter.search(GetRemoteManga.QUERY_LATEST)
|
presenter.search(GetRemoteManga.QUERY_LATEST)
|
||||||
},
|
},
|
||||||
leadingIcon = {
|
leadingIcon = {
|
||||||
|
@ -44,7 +44,7 @@ fun SourceSearchScreen(
|
|||||||
placeholderText = stringResource(R.string.action_search_hint),
|
placeholderText = stringResource(R.string.action_search_hint),
|
||||||
navigateUp = navigateUp,
|
navigateUp = navigateUp,
|
||||||
onResetClick = { presenter.searchQuery = "" },
|
onResetClick = { presenter.searchQuery = "" },
|
||||||
onSearchClick = { presenter.search() },
|
onSearchClick = { presenter.search(it) },
|
||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -40,7 +40,7 @@ fun BrowseSourceToolbar(
|
|||||||
navigateUp: () -> Unit,
|
navigateUp: () -> Unit,
|
||||||
onWebViewClick: () -> Unit,
|
onWebViewClick: () -> Unit,
|
||||||
onHelpClick: () -> Unit,
|
onHelpClick: () -> Unit,
|
||||||
onSearch: () -> Unit,
|
onSearch: (String) -> Unit,
|
||||||
scrollBehavior: TopAppBarScrollBehavior? = null,
|
scrollBehavior: TopAppBarScrollBehavior? = null,
|
||||||
) {
|
) {
|
||||||
if (state.searchQuery == null) {
|
if (state.searchQuery == null) {
|
||||||
@ -56,13 +56,17 @@ fun BrowseSourceToolbar(
|
|||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
val cancelSearch = { state.searchQuery = null }
|
||||||
BrowseSourceSearchToolbar(
|
BrowseSourceSearchToolbar(
|
||||||
searchQuery = state.searchQuery!!,
|
searchQuery = state.searchQuery!!,
|
||||||
onSearchQueryChanged = { state.searchQuery = it },
|
onSearchQueryChanged = { state.searchQuery = it },
|
||||||
placeholderText = stringResource(R.string.action_search_hint),
|
placeholderText = stringResource(R.string.action_search_hint),
|
||||||
navigateUp = { state.searchQuery = null },
|
navigateUp = cancelSearch,
|
||||||
onResetClick = { state.searchQuery = "" },
|
onResetClick = { state.searchQuery = "" },
|
||||||
onSearchClick = onSearch,
|
onSearchClick = {
|
||||||
|
onSearch(it)
|
||||||
|
cancelSearch()
|
||||||
|
},
|
||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -165,7 +169,7 @@ fun BrowseSourceSearchToolbar(
|
|||||||
placeholderText: String?,
|
placeholderText: String?,
|
||||||
navigateUp: () -> Unit,
|
navigateUp: () -> Unit,
|
||||||
onResetClick: () -> Unit,
|
onResetClick: () -> Unit,
|
||||||
onSearchClick: () -> Unit,
|
onSearchClick: (String) -> Unit,
|
||||||
scrollBehavior: TopAppBarScrollBehavior?,
|
scrollBehavior: TopAppBarScrollBehavior?,
|
||||||
) {
|
) {
|
||||||
val keyboardController = LocalSoftwareKeyboardController.current
|
val keyboardController = LocalSoftwareKeyboardController.current
|
||||||
@ -178,7 +182,7 @@ fun BrowseSourceSearchToolbar(
|
|||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onSearch = {
|
onSearch = {
|
||||||
onSearchClick()
|
onSearchClick(searchQuery)
|
||||||
focusManager.clearFocus()
|
focusManager.clearFocus()
|
||||||
keyboardController?.hide()
|
keyboardController?.hide()
|
||||||
},
|
},
|
||||||
|
@ -119,7 +119,10 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
private fun navigateUp() {
|
private fun navigateUp() {
|
||||||
when {
|
when {
|
||||||
presenter.searchQuery != null -> presenter.searchQuery = null
|
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()
|
else -> router.popCurrentController()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,10 +135,10 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
filterSheet = SourceFilterSheet(
|
filterSheet = SourceFilterSheet(
|
||||||
activity!!,
|
activity!!,
|
||||||
onFilterClicked = {
|
onFilterClicked = {
|
||||||
presenter.setSourceFilter(presenter.filters)
|
presenter.search(filters = presenter.filters)
|
||||||
},
|
},
|
||||||
onResetClicked = {
|
onResetClicked = {
|
||||||
presenter.resetFilter()
|
presenter.reset()
|
||||||
filterSheet?.setFilters(presenter.filterItems)
|
filterSheet?.setFilters(presenter.filterItems)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -190,10 +193,9 @@ open class BrowseSourceController(bundle: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (genreExists) {
|
if (genreExists) {
|
||||||
filterSheet?.setFilters(presenter.filterItems)
|
filterSheet?.setFilters(defaultFilters.toItems())
|
||||||
|
|
||||||
presenter.searchQuery = ""
|
presenter.search(filters = defaultFilters)
|
||||||
presenter.setFilter(defaultFilters)
|
|
||||||
} else {
|
} else {
|
||||||
searchWithQuery(genreName)
|
searchWithQuery(genreName)
|
||||||
}
|
}
|
||||||
|
@ -155,22 +155,25 @@ open class BrowseSourcePresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setFilter(filters: FilterList) {
|
fun reset() {
|
||||||
state.filters = filters
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resetFilter() {
|
|
||||||
state.filters = source!!.getFilterList()
|
state.filters = source!!.getFilterList()
|
||||||
if (currentFilter !is Filter.UserInput) return
|
if (currentFilter !is Filter.UserInput) return
|
||||||
state.currentFilter = (currentFilter as Filter.UserInput).copy(filters = state.filters)
|
state.currentFilter = (currentFilter as Filter.UserInput).copy(filters = state.filters)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun search(query: String? = null) {
|
fun search(query: String? = null, filters: FilterList? = null) {
|
||||||
var new = Filter.valueOf(query ?: searchQuery ?: "")
|
Filter.valueOf(query ?: "").let {
|
||||||
if (new is Filter.UserInput && currentFilter is Filter.UserInput) {
|
if (it !is Filter.UserInput) {
|
||||||
new = new.copy(filters = currentFilter.filters)
|
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?) {
|
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.
|
* Get user categories.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user