Fix default group disappearing when empty

This commit is contained in:
Rafał Kobyłko 2024-08-12 00:15:44 +02:00
parent 5c6a149b03
commit bc72864377

View File

@ -111,18 +111,13 @@ internal class ServicesViewModel(
groupedServices.forEach { (group, services) ->
if (groupedServices.size > 1) {
if (group.id != null || services.isNotEmpty() || result.searchQuery.isNotEmpty()) {
val localGroup = result.groups.first { it.id == group.id }
add(
ServicesListItem.GroupItem(
if (result.searchQuery.isNotEmpty()) {
localGroup.copy(isExpanded = true)
} else {
localGroup
}
add(
ServicesListItem.GroupItem(
group = group.copy(
isExpanded = if (result.searchQuery.isNotEmpty()) true else group.isExpanded
)
)
}
)
}
if (group.isExpanded || result.isInEditMode || groupedServices.size == 1 || result.searchQuery.isNotEmpty()) {