mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
parent
6fc1f4fc21
commit
3061f198e9
@ -547,14 +547,7 @@ class LibraryPresenter(
|
|||||||
loadedManga[categoryId] ?: emptyList()
|
loadedManga[categoryId] ?: emptyList()
|
||||||
}
|
}
|
||||||
return remember(unfiltered, searchQuery) {
|
return remember(unfiltered, searchQuery) {
|
||||||
val query = searchQuery
|
if (searchQuery.isNullOrBlank()) unfiltered else unfiltered.filter { it.filter(searchQuery!!) }
|
||||||
if (query.isNullOrBlank().not()) {
|
|
||||||
unfiltered.filter {
|
|
||||||
it.filter(query!!)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unfiltered
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,7 +576,9 @@ class LibraryPresenter(
|
|||||||
add(manga)
|
add(manga)
|
||||||
return@apply
|
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 lastMangaIndex = items.indexOf(lastSelected)
|
||||||
val curMangaIndex = items.indexOf(manga)
|
val curMangaIndex = items.indexOf(manga)
|
||||||
val selectedIds = fastMap { it.id }
|
val selectedIds = fastMap { it.id }
|
||||||
@ -597,8 +592,10 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
fun selectAll(index: Int) {
|
fun selectAll(index: Int) {
|
||||||
state.selection = state.selection.toMutableList().apply {
|
state.selection = state.selection.toMutableList().apply {
|
||||||
val categoryId = categories[index].id
|
val categoryId = categories.getOrNull(index)?.id ?: -1
|
||||||
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 selectedIds = fastMap { it.id }
|
||||||
val newSelections = items.filterNot { it.id in selectedIds }
|
val newSelections = items.filterNot { it.id in selectedIds }
|
||||||
addAll(newSelections)
|
addAll(newSelections)
|
||||||
@ -608,7 +605,9 @@ class LibraryPresenter(
|
|||||||
fun invertSelection(index: Int) {
|
fun invertSelection(index: Int) {
|
||||||
state.selection = selection.toMutableList().apply {
|
state.selection = selection.toMutableList().apply {
|
||||||
val categoryId = categories[index].id
|
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 selectedIds = fastMap { it.id }
|
||||||
val (toRemove, toAdd) = items.partition { it.id in selectedIds }
|
val (toRemove, toAdd) = items.partition { it.id in selectedIds }
|
||||||
val toRemoveIds = toRemove.fastMap { it.id }
|
val toRemoveIds = toRemove.fastMap { it.id }
|
||||||
|
Loading…
Reference in New Issue
Block a user