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 79dcc4369..eab5e63f8 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 @@ -367,27 +367,28 @@ class LibraryScreenModel( // SY <-- // KMK --> - libraryPreferences.filterCategories().changes() + combine( + libraryPreferences.filterCategories().changes(), + libraryPreferences.filterCategoriesInclude().changes(), + libraryPreferences.filterCategoriesExclude().changes(), + ) { filter, included, excluded -> + Triple( + filter, + included.mapNotNull(String::toLongOrNull).toImmutableSet(), + excluded.mapNotNull(String::toLongOrNull).toImmutableSet(), + ) + } .distinctUntilChanged() - .onEach { + .onEach { (filter, included, excluded) -> mutableState.update { state -> - state.copy(filterCategory = it) + state.copy( + filterCategory = filter, + includedCategories = included, + excludedCategories = excluded, + ) } - }.launchIn(screenModelScope) - libraryPreferences.filterCategoriesInclude().changes() - .distinctUntilChanged() - .onEach { - mutableState.update { state -> - state.copy(includedCategories = it.mapNotNull(String::toLongOrNull).toImmutableSet()) - } - }.launchIn(screenModelScope) - libraryPreferences.filterCategoriesExclude().changes() - .distinctUntilChanged() - .onEach { - mutableState.update { state -> - state.copy(excludedCategories = it.mapNotNull(String::toLongOrNull).toImmutableSet()) - } - }.launchIn(screenModelScope) + } + .launchIn(screenModelScope) screenModelScope.launchIO { getCategories