Consider downloaded only mode when getting download counts in library

Fixes #8318

(cherry picked from commit ad107860b91d5b91f3e127904a0bd81c957f87c4)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt
This commit is contained in:
arkon 2022-10-28 21:29:25 -04:00 committed by Jobobby04
parent 38abaa162e
commit ef1242d067

View File

@ -205,12 +205,9 @@ class LibraryPresenter(
subscribeLibrary() subscribeLibrary()
} }
/**
* Subscribes to library if needed.
*/
fun subscribeLibrary() { fun subscribeLibrary() {
/** /**
* TODO: Move this to a coroutine world * TODO:
* - Move filter and sort to getMangaForCategory and only filter and sort the current display category instead of whole library as some has 5000+ items in the library * - Move filter and sort to getMangaForCategory and only filter and sort the current display category instead of whole library as some has 5000+ items in the library
* - Create new db view and new query to just fetch the current category save as needed to instance variable * - Create new db view and new query to just fetch the current category save as needed to instance variable
* - Fetch badges to maps and retrieve as needed instead of fetching all of them at once * - Fetch badges to maps and retrieve as needed instead of fetching all of them at once
@ -479,13 +476,18 @@ class LibraryPresenter(
getLibraryManga.subscribe(), getLibraryManga.subscribe(),
libraryPreferences.downloadBadge().changes(), libraryPreferences.downloadBadge().changes(),
libraryPreferences.filterDownloaded().changes(), libraryPreferences.filterDownloaded().changes(),
preferences.downloadedOnly().changes(),
downloadCache.changes, downloadCache.changes,
) { libraryMangaList, downloadBadgePref, filterDownloadedPref, _ -> ) { libraryMangaList, downloadBadgePref, filterDownloadedPref, downloadedOnly, _ ->
libraryMangaList libraryMangaList
.map { libraryManga -> .map { libraryManga ->
val needsDownloadCounts = downloadBadgePref ||
filterDownloadedPref != State.IGNORE.value ||
downloadedOnly
// Display mode based on user preference: take it from global library setting or category // Display mode based on user preference: take it from global library setting or category
LibraryItem(libraryManga).apply { LibraryItem(libraryManga).apply {
downloadCount = if (downloadBadgePref || filterDownloadedPref != State.IGNORE.value) { downloadCount = if (needsDownloadCounts) {
// SY --> // SY -->
if (libraryManga.manga.source == MERGED_SOURCE_ID) { if (libraryManga.manga.source == MERGED_SOURCE_ID) {
runBlocking { runBlocking {