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.

(cherry picked from commit a8eebd824a50d4676cc31aec51ede94009b82851)

# Conflicts:
#	app/src/main/java/eu/kanade/domain/source/interactor/GetEnabledSources.kt
#	app/src/main/java/eu/kanade/domain/source/model/Source.kt
#	app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBrowseScreen.kt
This commit is contained in:
arkon 2022-11-11 15:35:10 -05:00 committed by Jobobby04
parent 053b18c37d
commit eb6d63956d
4 changed files with 1 additions and 17 deletions

View File

@ -33,7 +33,6 @@ class GetEnabledSources(
// SY <-- // SY <--
repository.getSources(), repository.getSources(),
) { pinnedSourceIds, (enabledLanguages, disabledSources, lastUsedSource), (excludedFromDataSaver, sourcesInCategories, sourceCategoriesFilter), sources -> ) { pinnedSourceIds, (enabledLanguages, disabledSources, lastUsedSource), (excludedFromDataSaver, sourcesInCategories, sourceCategoriesFilter), sources ->
val duplicatePins = preferences.duplicatePinnedSources().get()
val sourcesAndCategories = sourcesInCategories.map { val sourcesAndCategories = sourcesInCategories.map {
it.split('|').let { (source, test) -> source.toLong() to test } it.split('|').let { (source, test) -> source.toLong() to test }
} }
@ -58,10 +57,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))
}
// SY --> // SY -->
categories.forEach { category -> categories.forEach { category ->
toFlatten.add(source.copy(category = category, pin = source.pin - Pin.Actual)) toFlatten.add(source.copy(category = category, pin = source.pin - Pin.Actual))

View File

@ -19,7 +19,7 @@ data class Source(
val category: String? = null, val category: String? = null,
val isExcludedFromDataSaver: Boolean = false, val isExcludedFromDataSaver: Boolean = false,
val categories: Set<String> = emptySet(), val categories: Set<String> = emptySet(),
// SY <-- // SY <--
) { ) {
val visualName: String val visualName: String
@ -38,7 +38,6 @@ data class Source(
val key: () -> String = { val key: () -> String = {
when { when {
isUsedLast -> "$id-lastused" isUsedLast -> "$id-lastused"
Pin.Forced in pin -> "$id-forced"
category != null -> "$id-$category" category != null -> "$id-$category"
else -> "$id" else -> "$id"
} }
@ -49,7 +48,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

@ -58,13 +58,6 @@ class SettingsBrowseScreen : SearchableSettings {
}, },
) )
}, },
// SY <--
Preference.PreferenceItem.SwitchPreference(
pref = sourcePreferences.duplicatePinnedSources(),
title = stringResource(R.string.pref_duplicate_pinned_sources),
subtitle = stringResource(R.string.pref_duplicate_pinned_sources_summary),
),
// SY -->
Preference.PreferenceItem.SwitchPreference( Preference.PreferenceItem.SwitchPreference(
pref = sourcePreferences.sourcesTabCategoriesFilter(), pref = sourcePreferences.sourcesTabCategoriesFilter(),
title = stringResource(R.string.pref_source_source_filtering), title = stringResource(R.string.pref_source_source_filtering),

View File

@ -450,8 +450,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>