diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt index df1fd86927..030193b57c 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatSections.kt @@ -1,6 +1,5 @@ package chat.simplex.common.views.chat -import androidx.compose.runtime.snapshots.SnapshotStateList import chat.simplex.common.model.* import chat.simplex.common.platform.chatModel import kotlinx.coroutines.Dispatchers @@ -26,7 +25,7 @@ data class ChatSection ( data class SectionItems ( val mergeCategory: CIMergeCategory?, - val items: SnapshotStateList, + val items: MutableList, val revealed: Boolean, val showAvatar: MutableSet, val itemPositions: MutableMap @@ -60,7 +59,7 @@ fun List.putIntoSections(revealedItems: Set): List SectionItems( mergeCategory = first.mergeCategory, - items = SnapshotStateList().also { it.add(first) }, + items = mutableListOf().also { it.add(first) }, revealed = first.mergeCategory == null || revealedItems.contains(first.id), showAvatar = mutableSetOf().also { if (first.chatDir is CIDirection.GroupRcv) { @@ -105,7 +104,7 @@ fun List.putIntoSections(revealedItems: Set): List if (existingSection == null) { val newSection = SectionItems( mergeCategory = item.mergeCategory, - items = SnapshotStateList().also { it.add(item) }, + items = mutableListOf().also { it.add(item) }, revealed = item.mergeCategory == null || revealedItems.contains(item.id), showAvatar = mutableSetOf().also { it.add(item.id) @@ -128,7 +127,7 @@ fun List.putIntoSections(revealedItems: Set): List } else { val newSectionItems = SectionItems( mergeCategory = item.mergeCategory, - items = SnapshotStateList().also { it.add(item) }, + items = mutableListOf().also { it.add(item) }, revealed = item.mergeCategory == null || revealedItems.contains(item.id), showAvatar = mutableSetOf().also { if (item.chatDir is CIDirection.GroupRcv && (prev.chatDir !is CIDirection.GroupRcv || (prev.chatDir as CIDirection.GroupRcv).groupMember.memberId != item.chatDir.groupMember.memberId)) { diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index e38df5a5d0..384d8bdc8e 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -1007,7 +1007,7 @@ fun BoxWithConstraintsScope.ChatItemsList( Spacer(Modifier.size(8.dp)) val reversedChatItems by remember { derivedStateOf { chatModel.chatItems.asReversed() } } val revealedItems = rememberSaveable { mutableStateOf(setOf()) } - val sections by remember { derivedStateOf { (reversedChatItems).putIntoSections(revealedItems.value) } } + val sections by remember { derivedStateOf { reversedChatItems.putIntoSections(revealedItems.value) } } val preloadItemsEnabled = remember { mutableStateOf(true) } val boundaries = remember { derivedStateOf { sections.map { it.boundary } } }