From 650c2dc6e787313e56d34fdd96bb0bbced821e8c Mon Sep 17 00:00:00 2001 From: MatchaSoba <76941874+MatchaSoba@users.noreply.github.com> Date: Sat, 30 Jul 2022 23:53:25 +0800 Subject: [PATCH] Fix logic for searchWithGenre (#7559) (cherry picked from commit b563e85c3b744595272718f7e82e3272e2a7c57b) --- .../source/browse/BrowseSourceController.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt index 313ccf2736..ab20ee493d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceController.kt @@ -343,11 +343,11 @@ open class BrowseSourceController(bundle: Bundle) : * @param genreName the name of the genre */ fun searchWithGenre(genreName: String) { - presenter.sourceFilters = presenter.source.getFilterList() + val defaultFilters = presenter.source.getFilterList() - var filterList: FilterList? = null + var genreExists = false - filter@ for (sourceFilter in presenter.sourceFilters) { + filter@ for (sourceFilter in defaultFilters) { if (sourceFilter is Filter.Group<*>) { for (filter in sourceFilter.state) { if (filter is Filter<*> && filter.name.equals(genreName, true)) { @@ -356,7 +356,7 @@ open class BrowseSourceController(bundle: Bundle) : is Filter.CheckBox -> filter.state = true else -> {} } - filterList = presenter.sourceFilters + genreExists = true break@filter } } @@ -366,19 +366,20 @@ open class BrowseSourceController(bundle: Bundle) : if (index != -1) { sourceFilter.state = index - filterList = presenter.sourceFilters + genreExists = true break } } } - if (filterList != null) { + if (genreExists) { + presenter.sourceFilters = defaultFilters filterSheet?.setFilters(presenter.filterItems) showProgressBar() adapter?.clear() - presenter.restartPager("", filterList) + presenter.restartPager("", defaultFilters) } else { searchWithQuery(genreName) }