refactoring of last pr

This commit is contained in:
Jays2Kings 2022-07-03 13:27:10 -04:00
parent a1320c5c26
commit 6a37d0f60d
2 changed files with 5 additions and 6 deletions

View file

@ -167,7 +167,6 @@ class LibraryController(
* Library search query.
*/
private var query = ""
private var oldShowAllCategories = true
/**
* Currently selected mangas.
@ -1267,11 +1266,10 @@ class LibraryController(
fun search(query: String?): Boolean {
if (!query.isNullOrBlank() && this.query.isBlank() && !presenter.showAllCategories) {
oldShowAllCategories = presenter.showAllCategories
preferences.showAllCategories().set(true)
presenter.forceShowAllCategories = true
presenter.getLibrary()
} else if (query.isNullOrBlank() && this.query.isNotBlank() && !oldShowAllCategories) {
preferences.showAllCategories().set(oldShowAllCategories)
} else if (query.isNullOrBlank() && this.query.isNotBlank() && presenter.forceShowAllCategories) {
presenter.forceShowAllCategories = false
presenter.getLibrary()
}

View file

@ -90,8 +90,9 @@ class LibraryPresenter(
private set
var allLibraryItems: List<LibraryItem> = emptyList()
private set
var forceShowAllCategories = false
val showAllCategories
get() = preferences.showAllCategories().get()
get() = forceShowAllCategories || preferences.showAllCategories().get()
private val libraryIsGrouped
get() = groupType != UNGROUPED