From ac1bed38f93e6b8e51b6f8cc2dae97c7ccb5f9b6 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 27 Nov 2022 10:43:38 -0500 Subject: [PATCH] Show empty library message properly Fixes #8632 The `library` map still contains the default category even when "empty". --- .../main/java/eu/kanade/tachiyomi/ui/library/LibraryScreen.kt | 4 ++-- .../java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreen.kt index 41149f130e..9f8f76bc9c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreen.kt @@ -134,7 +134,7 @@ object LibraryScreen : Screen { return@Scaffold } - if (state.searchQuery.isNullOrEmpty() && state.library.isEmpty()) { + if (state.searchQuery.isNullOrEmpty() && state.libraryCount == 0) { val handler = LocalUriHandler.current EmptyScreen( textResource = R.string.information_empty_library, @@ -156,7 +156,7 @@ object LibraryScreen : Screen { selection = state.selection, contentPadding = contentPadding, currentPage = { screenModel.activeCategory }, - isLibraryEmpty = state.library.isEmpty(), + isLibraryEmpty = state.libraryCount == 0, showPageTabs = state.showCategoryTabs, onChangeCurrentPage = { screenModel.activeCategory = it }, onMangaClicked = { router.openManga(it) }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index 2b4d8cce6a..2993099393 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -10,6 +10,7 @@ import cafe.adriel.voyager.core.model.coroutineScope import eu.kanade.core.prefs.CheckboxState import eu.kanade.core.prefs.PreferenceMutableState import eu.kanade.core.prefs.asState +import eu.kanade.core.util.fastDistinctBy import eu.kanade.core.util.fastFilter import eu.kanade.core.util.fastFilterNot import eu.kanade.core.util.fastMapNotNull @@ -750,7 +751,7 @@ class LibraryScreenModel( val libraryCount by lazy { library .flatMap { (_, v) -> v } - .distinctBy { it.libraryManga.manga.id } + .fastDistinctBy { it.libraryManga.manga.id } .size }