mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 22:45:06 +00:00
NewChatSheet: render filtered contacts in search mode (regression fix)
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.
This commit is contained in:
+47
-21
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user