From 7641bb4d0da8eb05d23c4e27c97dc2a75418d720 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 15 Sep 2020 17:53:01 -0400 Subject: [PATCH] Fix downloaded only filter --- app/src/main/java/eu/kanade/tachiyomi/Migrations.kt | 9 ++++++--- .../eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 0d6af6216..204ca4edf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -4,6 +4,7 @@ import androidx.core.content.edit import androidx.preference.PreferenceManager import eu.kanade.tachiyomi.data.backup.BackupCreatorJob import eu.kanade.tachiyomi.data.library.LibraryUpdateJob +import eu.kanade.tachiyomi.data.preference.PreferenceKeys import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.updater.UpdaterJob import eu.kanade.tachiyomi.extension.ExtensionUpdateJob @@ -100,12 +101,14 @@ object Migrations { return if (oldPrefValue) ExtendedNavigationView.Item.TriStateGroup.STATE_INCLUDE else ExtendedNavigationView.Item.TriStateGroup.STATE_IGNORE } - preferences.filterDownloaded().set(convertBooleanPrefToTriState("pref_filter_downloaded_key")) - preferences.filterUnread().set(convertBooleanPrefToTriState("pref_filter_unread_key")) - preferences.filterCompleted().set(convertBooleanPrefToTriState("pref_filter_completed_key")) prefs.edit { + putInt(PreferenceKeys.filterDownloaded, convertBooleanPrefToTriState("pref_filter_downloaded_key")) remove("pref_filter_downloaded_key") + + putInt(PreferenceKeys.filterUnread, convertBooleanPrefToTriState("pref_filter_unread_key")) remove("pref_filter_unread_key") + + putInt(PreferenceKeys.filterCompleted, convertBooleanPrefToTriState("pref_filter_completed_key")) remove("pref_filter_completed_key") } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 6e689f218..e94530c14 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -10,11 +10,11 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.MangaCategory import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.preference.PreferencesHelper -import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter +import eu.kanade.tachiyomi.util.isLocal import eu.kanade.tachiyomi.util.lang.combineLatest import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed import eu.kanade.tachiyomi.util.lang.launchIO @@ -134,9 +134,9 @@ class LibraryPresenter( } val filterFnDownloaded: (LibraryItem) -> Boolean = downloaded@{ item -> - if (filterDownloaded == STATE_IGNORE) return@downloaded true + if (!downloadedOnly && filterDownloaded == STATE_IGNORE) return@downloaded true val isDownloaded = when { - item.manga.source == LocalSource.ID -> true + item.manga.isLocal() -> true item.downloadCount != -1 -> item.downloadCount > 0 else -> downloadManager.getDownloadCount(item.manga) > 0 }