From f7cdcac57637086ec6315cd39e4ce7946f708cc5 Mon Sep 17 00:00:00 2001 From: another-simple-pixel Date: Mon, 18 May 2026 04:21:08 -0700 Subject: [PATCH] NewChatSheet: render filtered contacts in search mode (regression fix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 3a9ece8d1 moved contacts forEach inside the if-branch and made the else-branch fall back to NoFilteredContactsItem. That broke search: when the user typed text and the filter returned non-empty results, the if-condition (filtered.isNotEmpty() && searchText.isEmpty()) was false, the else ran NoFilteredContactsItem, NoFilteredContactsItem's internal guard saw a non-empty filter and rendered nothing — search results disappeared. Restore three-way branching with when{}: header + contacts in card when no search; contacts in plain card when search has matches; NoFilteredContactsItem when filter is empty. Applied at both OneHandLazyColumn and the regular layout. --- .../common/views/newchat/NewChatSheet.kt | 68 +++++++++++++------ 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt index 93bae3f295..f25b071b58 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt @@ -323,21 +323,34 @@ private fun ModalData.NewChatSheetLayout( DeletedChatsItem(actionButtonsOriginal.asReversed()) } item { - if (filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty()) { - SectionDividerSpaced(maxBottomPadding = false) - SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) { - filteredContactChats.forEachIndexed { index, chat -> - val nextChatSelected = remember(chat.id, filteredContactChats) { - derivedStateOf { - chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + when { + filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty() -> { + SectionDividerSpaced(maxBottomPadding = false) + SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) { + filteredContactChats.forEachIndexed { index, chat -> + val nextChatSelected = remember(chat.id, filteredContactChats) { + derivedStateOf { + chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + } } + ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) + } + } + Spacer(Modifier.height(DEFAULT_PADDING_HALF)) + } + filteredContactChats.isNotEmpty() -> { + SectionView { + filteredContactChats.forEachIndexed { index, chat -> + val nextChatSelected = remember(chat.id, filteredContactChats) { + derivedStateOf { + chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + } + } + ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) } - ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) } } - Spacer(Modifier.height(DEFAULT_PADDING_HALF)) - } else { - NoFilteredContactsItem() + else -> NoFilteredContactsItem() } } if (appPlatform.isAndroid) { @@ -408,20 +421,33 @@ private fun ModalData.NewChatSheetLayout( DeletedChatsItem(actionButtonsOriginal) } item { - if (filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty()) { - SectionDividerSpaced() - SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) { - filteredContactChats.forEachIndexed { index, chat -> - val nextChatSelected = remember(chat.id, filteredContactChats) { - derivedStateOf { - chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + when { + filteredContactChats.isNotEmpty() && searchText.value.text.isEmpty() -> { + SectionDividerSpaced() + SectionView(stringResource(MR.strings.contact_list_header_title), headerBottomPadding = DEFAULT_PADDING_HALF) { + filteredContactChats.forEachIndexed { index, chat -> + val nextChatSelected = remember(chat.id, filteredContactChats) { + derivedStateOf { + chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + } } + ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) } - ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) } } - } else { - NoFilteredContactsItem() + filteredContactChats.isNotEmpty() -> { + SectionView { + filteredContactChats.forEachIndexed { index, chat -> + val nextChatSelected = remember(chat.id, filteredContactChats) { + derivedStateOf { + chatModel.chatId.value != null && filteredContactChats.getOrNull(index + 1)?.id == chatModel.chatId.value + } + } + ContactListNavLinkView(chat, nextChatSelected, showDeletedChatIcon = true) + } + } + } + else -> NoFilteredContactsItem() } } if (appPlatform.isAndroid) {