mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-17 06:27:29 +01:00
Fix language in source filter list jumping to top incorrectly
Fixes #9068
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user