From 3ba6f84a4387e47d370ea46a0a9a88451f86023d Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 23 Feb 2023 18:50:48 -0500 Subject: [PATCH] Avoids changing the position of the the list when the list updates. --- .../amethyst/ui/screen/ThreadFeedView.kt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt index 5282b8a3a..f499c84b9 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/ThreadFeedView.kt @@ -78,15 +78,9 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A } } is FeedState.Loaded -> { - var noteIdPositionInThread by remember { mutableStateOf(0) } - // only in the first transition - LaunchedEffect(noteIdPositionInThread) { - listState.animateScrollToItem(noteIdPositionInThread, 0) - } - - val notePosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull() - if (notePosition != null) { - noteIdPositionInThread = state.feed.value.indexOf(notePosition) + LaunchedEffect(noteId) { + val noteForPosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull() + listState.animateScrollToItem(state.feed.value.indexOf(noteForPosition), 0) } LazyColumn(