remove other sections when jump to bottom clicked

This commit is contained in:
Diogo
2024-10-29 16:52:43 +00:00
parent 71d891acc2
commit 7ad0a2dd87

View File

@@ -1347,7 +1347,13 @@ fun BoxWithConstraintsScope.ChatItemsList(
scope.launch {
listState.animateScrollToItem(0)
preloadItemsEnabled.value = true
// TODO: Remove other sections and items.
val bottomSection = sections.find { it.area == ChatSectionArea.Bottom }
if (bottomSection != null && sections.size > 1) {
val removeTo = chatModel.chatItems.value.size - 1 - bottomSection.boundary.maxIndex
chatModel.chatItems.value.removeRange(fromIndex = 0, toIndex = removeTo)
chatModel.chatItemsSectionArea = mutableMapOf<Long, ChatSectionArea>().also { it.putAll(chatModel.chatItems.value.associate { it.id to ChatSectionArea.Bottom }) }
}
}
}