fix: split tunnel sort checked to top

closes #882
This commit is contained in:
Zane Schepke
2025-09-18 23:53:45 -04:00
parent 1127db1c56
commit 274e6aec0f
2 changed files with 9 additions and 3 deletions
@@ -36,13 +36,13 @@ fun SplitTunnelScreen(tunnelId: Int, viewModel: SplitTunnelViewModel = hiltViewM
val conf by remember { derivedStateOf { tunnelConf.toAmConfig() } }
var splitConfig by remember {
mutableStateOf<Pair<SplitOption, Set<String>>>(
mutableStateOf(
when {
conf.`interface`.excludedApplications.isNotEmpty() ->
Pair(SplitOption.EXCLUDE, conf.`interface`.excludedApplications.toSet())
conf.`interface`.includedApplications.isNotEmpty() ->
Pair(SplitOption.INCLUDE, conf.`interface`.includedApplications.toSet())
else -> Pair(SplitOption.ALL, emptySet())
else -> Pair(SplitOption.ALL, emptySet<String>())
}
)
}
@@ -31,6 +31,7 @@ fun AppListSection(
) {
var query by remember { mutableStateOf("") }
val locale = remember { Locale.getDefault() }
val filteredAndSortedPackages by remember {
derivedStateOf {
@@ -40,7 +41,12 @@ fun AppListSection(
pkg.name.contains(query, ignoreCase = true) ||
pkg.packageName.contains(query, ignoreCase = true)
}
.sortedBy { pkg -> pkg.name.lowercase(Locale.getDefault()) }
.sortedWith(
compareByDescending<InstalledPackage> {
splitConfig.second.contains(it.packageName)
}
.thenBy { it.name.lowercase(locale) }
)
}
}