This commit is contained in:
Avently
2024-11-01 19:09:54 +07:00
parent 089e5f6ec1
commit 494724de01
2 changed files with 3 additions and 3 deletions
@@ -236,7 +236,7 @@ fun landingSectionToArea(chatLandingSection: ChatLandingSection) = when (chatLan
ChatLandingSection.Unread -> ChatSectionArea.Current
}
suspend fun apiLoadBottomSection(chatInfo: ChatInfo, chatModel: ChatModel, rhId: Long?) {
suspend fun apiLoadBottomSection(chatInfo: ChatInfo, rhId: Long?) {
val chat = chatController.apiGetChat(rh = rhId, type = chatInfo.chatType, id = chatInfo.apiId)
if (chatModel.chatId.value != chatInfo.id || chat == null) return
withContext(Dispatchers.Main) {
@@ -1002,6 +1002,7 @@ fun BoxScope.ChatItemsList(
val topPaddingToContentPx = rememberUpdatedState(with(LocalDensity.current) { topPaddingToContent().roundToPx() })
val maxHeight = remember { derivedStateOf { listState.layoutInfo.viewportEndOffset - topPaddingToContentPx.value } }
val chatInfoUpdated = rememberUpdatedState(chatInfo)
LaunchedEffect(Unit) {
launch {
@@ -1023,7 +1024,7 @@ fun BoxScope.ChatItemsList(
withBGApi {
scrollAdjustmentEnabled.value = false
try {
apiLoadBottomSection(chatInfo, chatModel, remoteHostId)
apiLoadBottomSection(chatInfoUpdated.value, remoteHostId)
} finally {
delay(600)
scrollAdjustmentEnabled.value = true
@@ -1034,7 +1035,6 @@ fun BoxScope.ChatItemsList(
}
}
}
val chatInfoUpdated = rememberUpdatedState(chatInfo)
val scrollToItem: State<(Long) -> Unit> = remember {
mutableStateOf({ itemId: Long ->
val index = sections.value.chatItemPosition(itemId)