Add option to hide entries already in library when browsing sources
Closes #2941 (cherry picked from commit 6348cbaeb7dc786309c1ed811ff23114583144a8) # Conflicts: # app/src/main/java/eu/kanade/domain/source/service/SourcePreferences.kt # app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt
This commit is contained in:
parent
9872ee7ab9
commit
8fc9e77b77
@ -32,6 +32,8 @@ class SourcePreferences(
|
||||
|
||||
fun searchPinnedSourcesOnly() = preferenceStore.getBoolean("search_pinned_sources_only", false)
|
||||
|
||||
fun hideInLibraryItems() = preferenceStore.getBoolean("browse_hide_in_library_items", false)
|
||||
|
||||
// SY -->
|
||||
fun enableSourceBlacklist() = preferenceStore.getBoolean("eh_enable_source_blacklist", true)
|
||||
|
||||
|
@ -112,12 +112,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(
|
||||
|
@ -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
|
||||
@ -212,19 +213,20 @@ open class BrowseSourceScreenModel(
|
||||
// SY -->
|
||||
createSourcePagingSource(listing.query ?: "", listing.filters)
|
||||
// SY <--
|
||||
}.flow
|
||||
.map { pagingData ->
|
||||
pagingData.map { (sManga, metadata) ->
|
||||
val dbManga = withIOContext { networkToLocalManga.await(sManga.toDomainManga(sourceId)) }
|
||||
}.flow.map { pagingData ->
|
||||
pagingData
|
||||
.map { (it, metadata) -> withIOContext { networkToLocalManga.await(it.toDomainManga(sourceId)) } to metadata }
|
||||
.filter { (it) -> !sourcePreferences.hideInLibraryItems().get() || !it.favorite }
|
||||
.map { (dbManga, metadata) ->
|
||||
getManga.subscribe(dbManga.url, dbManga.source)
|
||||
.filterNotNull()
|
||||
.onEach { initializeManga(it) }
|
||||
.onEach(::initializeManga)
|
||||
// SY -->
|
||||
.combineMetadata(dbManga, metadata)
|
||||
// SY <--
|
||||
.stateIn(coroutineScope)
|
||||
}
|
||||
}
|
||||
}
|
||||
.cachedIn(coroutineScope)
|
||||
}
|
||||
.stateIn(coroutineScope, SharingStarted.Lazily, emptyFlow())
|
||||
|
@ -457,7 +457,8 @@
|
||||
|
||||
<!-- Browse section -->
|
||||
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string>
|
||||
<string name="pref_search_pinned_sources_only">Only include pinned sources</string>
|
||||
<string name="pref_search_pinned_sources_only">Only search pinned sources in global search</string>
|
||||
<string name="pref_hide_in_library_items">Hide entries already in library</string>
|
||||
|
||||
<!-- Backup section -->
|
||||
<string name="pref_create_backup">Create backup</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user