Fixing a bug where the last message is remembered by the Compose when forcing index = 0 on the first element.
This commit is contained in:
@@ -50,6 +50,11 @@ fun ChatroomFeedView(viewModel: FeedViewModel, accountViewModel: AccountViewMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
is FeedState.Loaded -> {
|
is FeedState.Loaded -> {
|
||||||
|
LaunchedEffect(state.feed.value.firstOrNull()) {
|
||||||
|
if (listState.firstVisibleItemIndex <= 1)
|
||||||
|
listState.animateScrollToItem(0)
|
||||||
|
}
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = PaddingValues(
|
contentPadding = PaddingValues(
|
||||||
top = 10.dp,
|
top = 10.dp,
|
||||||
@@ -59,7 +64,7 @@ fun ChatroomFeedView(viewModel: FeedViewModel, accountViewModel: AccountViewMode
|
|||||||
state = listState
|
state = listState
|
||||||
) {
|
) {
|
||||||
var previousDate: String = ""
|
var previousDate: String = ""
|
||||||
itemsIndexed(state.feed.value, key = { index, item -> if (index == 0) index else item.idHex }) { index, item ->
|
itemsIndexed(state.feed.value, key = { index, item -> item.idHex }) { index, item ->
|
||||||
ChatroomMessageCompose(item, routeForLastRead, accountViewModel = accountViewModel, navController = navController)
|
ChatroomMessageCompose(item, routeForLastRead, accountViewModel = accountViewModel, navController = navController)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user