diff --git a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt index 626c56544..c81fa1632 100644 --- a/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt @@ -31,4 +31,6 @@ class SourcePreferences( fun trustedSignatures() = preferenceStore.getStringSet("trusted_signatures", emptySet()) fun searchPinnedSourcesOnly() = preferenceStore.getBoolean("search_pinned_sources_only", false) + + fun hideInLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false) } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt index 2e0c8f9cf..773a896c0 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt @@ -43,12 +43,16 @@ object SettingsBrowseScreen : SearchableSettings { ), ), Preference.PreferenceGroup( - title = stringResource(R.string.action_global_search), + title = stringResource(R.string.label_sources), preferenceItems = listOf( Preference.PreferenceItem.SwitchPreference( pref = sourcePreferences.searchPinnedSourcesOnly(), title = stringResource(R.string.pref_search_pinned_sources_only), ), + Preference.PreferenceItem.SwitchPreference( + pref = sourcePreferences.hideInLibraryItems(), + title = stringResource(R.string.pref_hide_in_library_items), + ), ), ), Preference.PreferenceGroup( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt index 6c2e5fc57..ef6b1b061 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.cachedIn +import androidx.paging.filter import androidx.paging.map import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.coroutineScope @@ -137,16 +138,17 @@ class BrowseSourceScreenModel( PagingConfig(pageSize = 25), ) { getRemoteManga.subscribe(sourceId, listing.query ?: "", listing.filters) - }.flow - .map { pagingData -> - pagingData.map { sManga -> - val dbManga = withIOContext { networkToLocalManga.await(sManga.toDomainManga(sourceId)) } - getManga.subscribe(dbManga.url, dbManga.source) + }.flow.map { pagingData -> + pagingData + .map { withIOContext { networkToLocalManga.await(it.toDomainManga(sourceId)) } } + .filter { !sourcePreferences.hideInLibraryItems().get() || !it.favorite } + .map { + getManga.subscribe(it.url, it.source) .filterNotNull() - .onEach { initializeManga(it) } + .onEach(::initializeManga) .stateIn(coroutineScope) } - } + } .cachedIn(coroutineScope) } .stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow()) diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 8036e4058..9c61e0ea7 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -457,7 +457,8 @@ Check for extension updates - Only include pinned sources + Only search pinned sources in global search + Hide entries already in library Create backup