From 94a5702011c4ddeed8c44ff656971f7ca4ac6ab3 Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Tue, 11 Oct 2022 20:03:38 +0300 Subject: [PATCH] Do not scroll to active item --- .../src/main/java/chat/simplex/app/views/chat/ChatView.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt index cca53b3f33..e762a39864 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ChatView.kt @@ -501,9 +501,12 @@ fun BoxWithConstraintsScope.ChatItemsList( if (cItem.content.msgContent is MsgContent.MCImage) { val itemsWithImages by lazy { chatItems.filter { it.content.msgContent is MsgContent.MCImage && it.file?.loaded == true } } ImageGalleryProvider.from(cItem.id, { itemsWithImages }) { dismissedIndex -> + val indexInReversed = reversedChatItems.indexOfFirst { it.id == itemsWithImages[dismissedIndex].id } + // Do not scroll to this item, just to different items + if (indexInReversed == i) return@from scope.launch { listState.scrollToItem( - kotlin.math.min(reversedChatItems.lastIndex, reversedChatItems.indexOfFirst { it.id == itemsWithImages[dismissedIndex].id } + 1), + kotlin.math.min(reversedChatItems.lastIndex, indexInReversed + 1), -maxHeightRounded / 2 ) }