fix(android): make chat day separator keys unique
Some checks failed
Android CI / android (push) Has started running
Android Release / release (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
Codex
2026-03-10 20:30:10 +03:00
parent 63c0cd098e
commit 842a9d2093

View File

@@ -675,7 +675,7 @@ fun ChatScreen(
items = timelineItems,
key = { item ->
when (item) {
is ChatTimelineItem.DayHeader -> "day:${item.dateKey}"
is ChatTimelineItem.DayHeader -> "day:${item.headerId}"
is ChatTimelineItem.MessageEntry -> "msg:${item.message.id}"
}
},
@@ -2047,6 +2047,7 @@ private fun FileAttachmentRow(
private sealed interface ChatTimelineItem {
data class DayHeader(
val headerId: String,
val dateKey: String,
val label: String,
) : ChatTimelineItem
@@ -2090,10 +2091,13 @@ private fun buildChatTimelineItems(messages: List<MessageItem>): List<ChatTimeli
if (messages.isEmpty()) return emptyList()
val items = mutableListOf<ChatTimelineItem>()
var previousDate: LocalDate? = null
var dayHeaderCounter = 0
messages.forEach { message ->
val date = parseMessageLocalDate(message.createdAt)
if (date != null && date != previousDate) {
dayHeaderCounter += 1
items += ChatTimelineItem.DayHeader(
headerId = "${date}_$dayHeaderCounter",
dateKey = date.toString(),
label = formatDateSeparatorLabel(date),
)