feat: Enhance message key uniqueness in ChatDetailScreen to prevent empty IDs

This commit is contained in:
k1ngsterr1
2026-01-13 04:17:48 +05:00
parent ae66d7972f
commit 564176eb31

View File

@@ -794,7 +794,10 @@ fun ChatDetailScreen(
) {
// Reversed layout: item 0 = самое новое сообщение (внизу экрана)
// messagesWithDates уже отсортирован новые->старые
itemsIndexed(messagesWithDates, key = { _, item -> item.first.id }) {
// Используем id + timestamp для уникальности ключа (защита от пустых id)
itemsIndexed(messagesWithDates, key = { index, item ->
item.first.id.ifEmpty { "msg_${item.first.timestamp.time}_$index" }
}) {
index,
(message, showDate) ->
// Определяем, показывать ли хвостик (последнее сообщение в группе)