Remove duplicate pinned sources setting

I guess it's simpler to just have 1 entry in the list (other than the last used duplicate).
This helps ensure that the list is as short as it can be.
This commit is contained in:
arkon 2022-11-11 15:35:10 -05:00
parent afa0a0a0e2
commit a8eebd824a
4 changed files with 0 additions and 19 deletions

View File

@ -23,7 +23,6 @@ class GetEnabledSources(
preferences.lastUsedSource().changes(), preferences.lastUsedSource().changes(),
repository.getSources(), repository.getSources(),
) { pinnedSourceIds, enabledLanguages, disabledSources, lastUsedSource, sources -> ) { pinnedSourceIds, enabledLanguages, disabledSources, lastUsedSource, sources ->
val duplicatePins = preferences.duplicatePinnedSources().get()
sources sources
.filter { it.lang in enabledLanguages || it.id == LocalSource.ID } .filter { it.lang in enabledLanguages || it.id == LocalSource.ID }
.filterNot { it.id.toString() in disabledSources } .filterNot { it.id.toString() in disabledSources }
@ -35,10 +34,6 @@ class GetEnabledSources(
if (source.id == lastUsedSource) { if (source.id == lastUsedSource) {
toFlatten.add(source.copy(isUsedLast = true, pin = source.pin - Pin.Actual)) toFlatten.add(source.copy(isUsedLast = true, pin = source.pin - Pin.Actual))
} }
if (duplicatePins && Pin.Pinned in source.pin) {
toFlatten[0] = toFlatten[0].copy(pin = source.pin + Pin.Forced)
toFlatten.add(source.copy(pin = source.pin - Pin.Actual))
}
toFlatten toFlatten
} }
} }

View File

@ -33,7 +33,6 @@ data class Source(
val key: () -> String = { val key: () -> String = {
when { when {
isUsedLast -> "$id-lastused" isUsedLast -> "$id-lastused"
Pin.Forced in pin -> "$id-forced"
else -> "$id" else -> "$id"
} }
} }
@ -43,7 +42,6 @@ sealed class Pin(val code: Int) {
object Unpinned : Pin(0b00) object Unpinned : Pin(0b00)
object Pinned : Pin(0b01) object Pinned : Pin(0b01)
object Actual : Pin(0b10) object Actual : Pin(0b10)
object Forced : Pin(0b100)
} }
inline fun Pins(builder: Pins.PinsBuilder.() -> Unit = {}): Pins { inline fun Pins(builder: Pins.PinsBuilder.() -> Unit = {}): Pins {

View File

@ -29,16 +29,6 @@ class SettingsBrowseScreen : SearchableSettings {
val sourcePreferences = remember { Injekt.get<SourcePreferences>() } val sourcePreferences = remember { Injekt.get<SourcePreferences>() }
val preferences = remember { Injekt.get<BasePreferences>() } val preferences = remember { Injekt.get<BasePreferences>() }
return listOf( return listOf(
Preference.PreferenceGroup(
title = stringResource(R.string.label_sources),
preferenceItems = listOf(
Preference.PreferenceItem.SwitchPreference(
pref = sourcePreferences.duplicatePinnedSources(),
title = stringResource(R.string.pref_duplicate_pinned_sources),
subtitle = stringResource(R.string.pref_duplicate_pinned_sources_summary),
),
),
),
Preference.PreferenceGroup( Preference.PreferenceGroup(
title = stringResource(R.string.label_extensions), title = stringResource(R.string.label_extensions),
preferenceItems = listOf( preferenceItems = listOf(

View File

@ -451,8 +451,6 @@
<string name="action_track">Track</string> <string name="action_track">Track</string>
<!-- Browse section --> <!-- Browse section -->
<string name="pref_duplicate_pinned_sources">Show duplicated pinned sources</string>
<string name="pref_duplicate_pinned_sources_summary">Repeat pinned sources in their respective language groups</string>
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string> <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 include pinned sources</string>