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

@@ -6,13 +6,14 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import tachiyomi.domain.source.model.Source
import tachiyomi.domain.source.repository.SourceRepository
import java.util.SortedMap
class GetLanguagesWithSources(
private val repository: SourceRepository,
private val preferences: SourcePreferences,
) {
fun subscribe(): Flow<Map<String, List<Source>>> {
fun subscribe(): Flow<SortedMap<String, List<Source>>> {
return combine(
preferences.enabledLanguages().changes(),
preferences.disabledSources().changes(),
@@ -23,7 +24,8 @@ class GetLanguagesWithSources(
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name },
)
sortedSources.groupBy { it.lang }
sortedSources
.groupBy { it.lang }
.toSortedMap(
compareBy<String> { it !in enabledLanguage }.then(LocaleHelper.comparator),
)