From 3a2e59a6e8bdbcfc96f22e140db95e37a9f51b6c Mon Sep 17 00:00:00 2001 From: Diogo Date: Fri, 1 Nov 2024 12:36:37 +0000 Subject: [PATCH] fix dropTemporarySections --- .../kotlin/chat/simplex/common/views/chat/ChatSections.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt index 6042b0cca3..2d6d4dcffb 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt @@ -220,10 +220,9 @@ fun List.revealedItemCount(): Int { fun List.dropTemporarySections() { val bottomSection = this.find { it.boundary.area == ChatSectionArea.Bottom } if (bottomSection != null) { - val items = chatModel.chatItems.value - val itemsOutsideOfSection = items.size - 1 - bottomSection.boundary.maxIndex + val itemsOutsideOfSection = chatModel.chatItems.value.size - 1 - bottomSection.boundary.maxIndex chatModel.chatItems.removeRange(fromIndex = 0, toIndex = itemsOutsideOfSection + bottomSection.excessItemCount()) - chatModel.chatItemsSectionArea = mutableMapOf().also { it.putAll(items.associate { it.id to ChatSectionArea.Bottom }) } + chatModel.chatItemsSectionArea = mutableMapOf().also { it.putAll(chatModel.chatItems.value.associate { it.id to ChatSectionArea.Bottom }) } } }