From 7ad0a2dd87a4692012aec0fbd2bcbe7234837f0a Mon Sep 17 00:00:00 2001 From: Diogo Date: Tue, 29 Oct 2024 16:52:43 +0000 Subject: [PATCH] remove other sections when jump to bottom clicked --- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 87b427641c..e38df5a5d0 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -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().also { it.putAll(chatModel.chatItems.value.associate { it.id to ChatSectionArea.Bottom }) } + } } }