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