Temporally Fix #8287 (#8493)

(cherry picked from commit 3061f198e9dc381e6294e05447b9798dcea885e4)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt
This commit is contained in:
Quang Kieu 2022-11-11 15:01:48 -05:00 committed by Jobobby04
parent 72f7b98742
commit 754feb6751

View File

@ -1031,7 +1031,9 @@ class LibraryPresenter(
add(manga)
return@apply
}
val items = loadedManga[manga.category].orEmpty().fastMap { it.libraryManga }
val items = loadedManga[manga.category].orEmpty().apply {
if (searchQuery.isNullOrBlank()) toList() else filter { it.filter(searchQuery!!) }
}.fastMap { it.libraryManga }
val lastMangaIndex = items.indexOf(lastSelected)
val curMangaIndex = items.indexOf(manga)
val selectedIds = fastMap { it.id }
@ -1045,8 +1047,10 @@ class LibraryPresenter(
fun selectAll(index: Int) {
state.selection = state.selection.toMutableList().apply {
val categoryId = categories[index].id
val items = loadedManga[categoryId].orEmpty().fastMap { it.libraryManga }
val categoryId = categories.getOrNull(index)?.id ?: -1
val items = loadedManga[categoryId].orEmpty().apply {
if (searchQuery.isNullOrBlank()) toList() else filter { it.filter(searchQuery!!) }
}.fastMap { it.libraryManga }
val selectedIds = fastMap { it.id }
val newSelections = items.filterNot { it.id in selectedIds }
addAll(newSelections)
@ -1056,7 +1060,9 @@ class LibraryPresenter(
fun invertSelection(index: Int) {
state.selection = selection.toMutableList().apply {
val categoryId = categories[index].id
val items = loadedManga[categoryId].orEmpty().fastMap { it.libraryManga }
val items = loadedManga[categoryId].orEmpty().apply {
if (searchQuery.isNullOrBlank()) toList() else filter { it.filter(searchQuery!!) }
}.fastMap { it.libraryManga }
val selectedIds = fastMap { it.id }
val (toRemove, toAdd) = items.partition { it.id in selectedIds }
val toRemoveIds = toRemove.fastMap { it.id }