mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-23 13:23:28 +03:00
Add option to hide entries already in library when browsing sources
Closes #2941
This commit is contained in:
parent
a7cb33d8c9
commit
6348cbaeb7
4 changed files with 18 additions and 9 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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…
Reference in a new issue