Fix language in source filter list jumping to top incorrectly

Fixes #9068
This commit is contained in:
arkon
2023-05-03 15:07:41 -04:00
parent 14c465d36f
commit f5ad95d78a
4 changed files with 28 additions and 20 deletions

View File

@@ -14,6 +14,7 @@ import kotlinx.coroutines.launch
import tachiyomi.domain.source.model.Source
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.util.SortedMap
class SourcesFilterScreenModel(
private val preferences: SourcePreferences = Injekt.get(),
@@ -66,7 +67,7 @@ sealed class SourcesFilterState {
) : SourcesFilterState()
data class Success(
val items: Map<String, List<Source>>,
val items: SortedMap<String, List<Source>>,
val enabledLanguages: Set<String>,
val disabledSources: Set<String>,
) : SourcesFilterState() {

View File

@@ -11,10 +11,14 @@ import java.util.Locale
*/
object LocaleHelper {
val comparator = compareBy<String>(
{ getDisplayName(it) },
{ it == "all" },
)
/**
* Sorts by display name, except keeps the "all" (displayed as "Multi") locale at the top.
*/
val comparator = { a: String, b: String ->
if (a == "all") -1
else if (b == "all") 1
else getDisplayName(a).compareTo(getDisplayName(b))
}
/**
* Returns display name of a string language code.