mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add option to hide entries already in library when browsing sources
Closes #2941
This commit is contained in:
		@@ -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())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user