mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Show empty category when searching with show all categories disabled
This commit is contained in:
parent
6897d45340
commit
f521050228
2 changed files with 10 additions and 13 deletions
|
@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.util.lang.removeArticles
|
|||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.system.timeSpanFromNow
|
||||
import eu.kanade.tachiyomi.util.system.withDefContext
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -130,17 +131,7 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
|
|||
}
|
||||
|
||||
private fun performFilter() {
|
||||
val s = getFilter(String::class.java)
|
||||
if (s.isNullOrBlank()) {
|
||||
if (mangas.firstOrNull()?.filter?.isNotBlank() == true) {
|
||||
mangas.forEach { it.filter = "" }
|
||||
}
|
||||
updateDataSet(mangas)
|
||||
} else {
|
||||
updateDataSet(mangas.filter { it.filter(s) })
|
||||
}
|
||||
isLongPressDragEnabled = libraryListener?.canDrag() == true && s.isNullOrBlank()
|
||||
setItemsPerCategoryMap()
|
||||
runBlocking { performFilterAsync() }
|
||||
}
|
||||
|
||||
suspend fun performFilterAsync() {
|
||||
|
@ -152,8 +143,14 @@ class LibraryCategoryAdapter(val controller: LibraryController?) :
|
|||
updateDataSet(mangas)
|
||||
} else {
|
||||
val filteredManga = withDefContext { mangas.filter { it.filter(s) } }
|
||||
if (filteredManga.isEmpty() && controller?.presenter?.showAllCategories == false) {
|
||||
val catId = mangas.firstOrNull()?.manga?.category
|
||||
val blankItem = catId?.let { controller.presenter.blankItem(it) }
|
||||
updateDataSet(blankItem ?: emptyList())
|
||||
} else {
|
||||
updateDataSet(filteredManga)
|
||||
}
|
||||
}
|
||||
isLongPressDragEnabled = libraryListener?.canDrag() == true && s.isNullOrBlank()
|
||||
setItemsPerCategoryMap()
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ class LibraryPresenter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun blankItem(id: Int = currentCategory): List<LibraryItem> {
|
||||
fun blankItem(id: Int = currentCategory): List<LibraryItem> {
|
||||
return listOf(
|
||||
LibraryItem(
|
||||
LibraryManga.createBlank(id),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue