Avoids changing the position of the the list when the list updates.

This commit is contained in:
Vitor Pamplona
2023-02-23 18:50:48 -05:00
parent a399aa0ddd
commit 3ba6f84a43

View File

@@ -78,15 +78,9 @@ fun ThreadFeedView(noteId: String, viewModel: FeedViewModel, accountViewModel: A
} }
} }
is FeedState.Loaded -> { is FeedState.Loaded -> {
var noteIdPositionInThread by remember { mutableStateOf(0) } LaunchedEffect(noteId) {
// only in the first transition val noteForPosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull()
LaunchedEffect(noteIdPositionInThread) { listState.animateScrollToItem(state.feed.value.indexOf(noteForPosition), 0)
listState.animateScrollToItem(noteIdPositionInThread, 0)
}
val notePosition = state.feed.value.filter { it.idHex == noteId}.firstOrNull()
if (notePosition != null) {
noteIdPositionInThread = state.feed.value.indexOf(notePosition)
} }
LazyColumn( LazyColumn(