consistent type for chatItemsSectionArea

This commit is contained in:
Diogo
2024-11-01 14:13:36 +00:00
parent 3a2e59a6e8
commit 122d5948af
4 changed files with 6 additions and 6 deletions

View File

@@ -66,7 +66,7 @@ object ChatModel {
// current chat
val chatId = mutableStateOf<String?>(null)
val chatItems = mutableStateOf(SnapshotStateList<ChatItem>())
var chatItemsSectionArea = mutableMapOf<Long, ChatSectionArea>()
val chatItemsSectionArea = mutableMapOf<Long, ChatSectionArea>()
// rhId, chatId
val deletedChats = mutableStateOf<List<Pair<Long?, String>>>(emptyList())
val chatItemStatuses = mutableMapOf<Long, CIStatus>()

View File

@@ -222,7 +222,8 @@ fun List<ChatSection>.dropTemporarySections() {
if (bottomSection != null) {
val itemsOutsideOfSection = chatModel.chatItems.value.size - 1 - bottomSection.boundary.maxIndex
chatModel.chatItems.removeRange(fromIndex = 0, toIndex = itemsOutsideOfSection + bottomSection.excessItemCount())
chatModel.chatItemsSectionArea = mutableMapOf<Long, ChatSectionArea>().also { it.putAll(chatModel.chatItems.value.associate { it.id to ChatSectionArea.Bottom }) }
chatModel.chatItemsSectionArea.clear()
chatModel.chatItems.value.associateTo(chatModel.chatItemsSectionArea) { it.id to ChatSectionArea.Bottom }
}
}

View File

@@ -29,7 +29,6 @@ import androidx.compose.ui.unit.*
import chat.simplex.common.model.*
import chat.simplex.common.model.CIDirection.GroupRcv
import chat.simplex.common.model.ChatController.appPrefs
import chat.simplex.common.model.ChatModel.chatItems
import chat.simplex.common.model.ChatModel.controller
import chat.simplex.common.model.ChatModel.withChats
import chat.simplex.common.ui.theme.*
@@ -1039,7 +1038,7 @@ fun BoxScope.ChatItemsList(
mutableStateOf({ itemId: Long ->
val index = sections.value.chatItemPosition(itemId)
preloadItemsEnabled.value = false
if (index != null) {
scope.launch {
listState.animateScrollToItem(scrollPosition.value(index), -maxHeight.value)

View File

@@ -1,7 +1,6 @@
package chat.simplex.common.views.chatlist
import SectionItemView
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
@@ -229,7 +228,8 @@ fun openLoadedChat(chat: Chat, chatModel: ChatModel, landingSection: ChatLanding
chatModel.chatItemStatuses.clear()
chatModel.chatItems.replaceAll(chat.chatItems)
chatModel.chatId.value = chat.chatInfo.id
chatModel.chatItemsSectionArea = mutableMapOf<Long, ChatSectionArea>().also { map -> map.putAll(chatModel.chatItems.value.associate { it.id to landingSectionToArea(landingSection) }) }
chatModel.chatItemsSectionArea.clear()
chat.chatItems.associateTo(chatModel.chatItemsSectionArea) { it.id to landingSectionToArea(landingSection) }
}
suspend fun apiLoadMessages(