From bc72864377f02a21e418a7b3ed5f323120e4ef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=C2=A0Koby=C5=82ko?= Date: Mon, 12 Aug 2024 00:15:44 +0200 Subject: [PATCH] Fix default group disappearing when empty --- .../feature/home/ui/services/ServicesViewModel.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/feature/home/src/main/java/com/twofasapp/feature/home/ui/services/ServicesViewModel.kt b/feature/home/src/main/java/com/twofasapp/feature/home/ui/services/ServicesViewModel.kt index ef9a7e0a..78afbebf 100644 --- a/feature/home/src/main/java/com/twofasapp/feature/home/ui/services/ServicesViewModel.kt +++ b/feature/home/src/main/java/com/twofasapp/feature/home/ui/services/ServicesViewModel.kt @@ -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()) {