Tweak library view (#8240)
- Move category join to improve performance - Move bookmark calculation into query - Move unread calculation into domain
This commit is contained in:
@@ -19,7 +19,6 @@ import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.domain.category.interactor.GetCategories
|
||||
import eu.kanade.domain.category.interactor.SetMangaCategories
|
||||
import eu.kanade.domain.category.model.Category
|
||||
import eu.kanade.domain.chapter.interactor.GetBookmarkedChaptersByMangaId
|
||||
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
||||
import eu.kanade.domain.chapter.interactor.SetReadStatus
|
||||
import eu.kanade.domain.chapter.model.toDbChapter
|
||||
@@ -55,7 +54,6 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import rx.Observable
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
@@ -84,7 +82,6 @@ class LibraryPresenter(
|
||||
private val getLibraryManga: GetLibraryManga = Injekt.get(),
|
||||
private val getTracks: GetTracks = Injekt.get(),
|
||||
private val getCategories: GetCategories = Injekt.get(),
|
||||
private val getBookmarkedChaptersByMangaId: GetBookmarkedChaptersByMangaId = Injekt.get(),
|
||||
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
||||
private val setReadStatus: SetReadStatus = Injekt.get(),
|
||||
private val updateManga: UpdateManga = Injekt.get(),
|
||||
@@ -218,14 +215,13 @@ class LibraryPresenter(
|
||||
|
||||
val filterFnBookmarked: (LibraryItem) -> Boolean = bookmarked@{ item ->
|
||||
if (filterBookmarked == State.IGNORE.value) return@bookmarked true
|
||||
return@bookmarked runBlocking {
|
||||
val isBookmarked = getBookmarkedChaptersByMangaId.await(item.libraryManga.manga.id).isNotEmpty()
|
||||
|
||||
return@runBlocking if (filterBookmarked == State.INCLUDE.value) {
|
||||
isBookmarked
|
||||
} else {
|
||||
!isBookmarked
|
||||
}
|
||||
val hasBookmarks = item.libraryManga.hasBookmarks
|
||||
|
||||
return@bookmarked if (filterBookmarked == State.INCLUDE.value) {
|
||||
hasBookmarks
|
||||
} else {
|
||||
!hasBookmarks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user