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

pull/152/head
Vitor Pamplona 2023-02-23 18:50:48 -05:00
rodzic a399aa0ddd
commit 3ba6f84a43
1 zmienionych plików z 3 dodań i 9 usunięć

Wyświetl plik

@ -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(