Trying move the cursor to the first item when the list updates immediately after being first drawn

This commit is contained in:
Vitor Pamplona
2023-03-02 09:35:43 -05:00
parent b95c013714
commit 65d4d59e77
2 changed files with 6 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.ui.note.NoteCompose import com.vitorpamplona.amethyst.ui.note.NoteCompose
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import kotlinx.coroutines.delay
@Composable @Composable
fun FeedView( fun FeedView(
@@ -96,6 +97,11 @@ private fun FeedLoaded(
) { ) {
val listState = rememberLazyListState() val listState = rememberLazyListState()
LaunchedEffect(Unit) {
delay(500)
listState.animateScrollToItem(0)
}
LazyColumn( LazyColumn(
contentPadding = PaddingValues( contentPadding = PaddingValues(
top = 10.dp, top = 10.dp,

View File

@@ -88,8 +88,6 @@ fun SearchScreen(accountViewModel: AccountViewModel, navController: NavControlle
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
feedViewModel.invalidateData() feedViewModel.invalidateData()
delay(500)
feedViewModel.invalidateData()
} }
DisposableEffect(accountViewModel) { DisposableEffect(accountViewModel) {