From 30606b5238cd859a72a0a3c0af2809ef30d29569 Mon Sep 17 00:00:00 2001 From: Diogo Date: Mon, 30 Sep 2024 10:05:50 +0100 Subject: [PATCH] safe get for lastVisibleItem --- .../kotlin/chat/simplex/common/views/chat/ChatView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 1ede0b5048..73aeb14eaf 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 @@ -1425,9 +1425,9 @@ fun BoxWithConstraintsScope.FloatingButtons( val lastVisibleItem by remember { derivedStateOf { - if (lastIndexOfVisibleItems >= 0) { + if (lastIndexOfVisibleItems >= 0 && firstVisibleIndex >= 0) { val lastVisibleChatItemIndex = chatItems.value.lastIndex - firstVisibleIndex - lastIndexOfVisibleItems - chatItems.value[lastVisibleChatItemIndex] + chatItems.value.getOrNull(lastVisibleChatItemIndex) } else { null }