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 629a13c83f..4bed8da7a3 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 @@ -249,8 +249,8 @@ fun List.dropTemporarySections() { } } -fun ChatSection.excessItemCount(): Int { - return max(boundary.maxIndex.minus(boundary.minIndex) + 1 - MAX_SECTION_SIZE, 0) +private fun ChatSection.excessItemCount(): Int { + return max(boundary.maxIndex - boundary.minIndex + 1 - MAX_SECTION_SIZE, 0) } fun landingSectionToArea(chatLandingSection: ChatLandingSection) = when (chatLandingSection) { 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 67ab008904..c0b8970b1e 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 @@ -1066,15 +1066,13 @@ fun BoxScope.ChatItemsList( scope.launch { if (idx != null) { listState.animateScrollToItem(scrollPosition.value(idx), -maxHeight.value) - withContext(Dispatchers.Main) { - if (!itemsToDrop.isNullOrEmpty()) { - itemsToDrop.forEach { - chatModel.chatItemsSectionArea.remove(it.id) - } - chatModel.chatItems.removeAll { chatModel.chatItemsSectionArea[it.id] == null } - val newIdx = reversedChatItems.value.indexOfFirst { it.id == itemId } - listState.scrollToItem(scrollPosition.value(newIdx), -maxHeight.value) + if (!itemsToDrop.isNullOrEmpty()) { + itemsToDrop.forEach { + chatModel.chatItemsSectionArea.remove(it.id) } + chatModel.chatItems.removeAll { chatModel.chatItemsSectionArea[it.id] == null } + val newIdx = reversedChatItems.value.indexOfFirst { it.id == itemId } + listState.scrollToItem(scrollPosition.value(newIdx), -maxHeight.value) } } preloadItemsEnabled.value = true