fix(dm): place date separators above whole day-group in reversed list
The conversation list uses reverseLayout with newest-to-oldest iteration, but emitted each day's date header right after the group's newest message. Because reverseLayout inverts emission order on screen, the divider landed just above the single newest message, pushing all older same-day messages up under the previous day's header. Only the latest message showed below its correct divider. Emit each day's header at the group's older boundary (using a lookahead to the next, older message) so reverseLayout renders it on top of the whole day-group.
This commit is contained in:
@@ -394,8 +394,8 @@ fun DmConversationScreen(
|
||||
reverseLayout = true,
|
||||
contentPadding = PaddingValues(bottom = with(density) { bottomBarHeightPx.toDp() })
|
||||
) {
|
||||
var lastDateKey = ""
|
||||
for (msg in messages.reversed()) {
|
||||
val ordered = messages.reversed() // newest -> oldest (reverseLayout draws index 0 at bottom)
|
||||
for ((i, msg) in ordered.withIndex()) {
|
||||
item(key = msg.id) {
|
||||
val icons = msg.relayUrls.map { url ->
|
||||
url to relayInfoRepo?.getIconUrl(url)
|
||||
@@ -422,9 +422,11 @@ fun DmConversationScreen(
|
||||
onOpenEmojiLibrary = onOpenEmojiLibrary
|
||||
)
|
||||
}
|
||||
// Emit each day's header at the group's older boundary so reverseLayout
|
||||
// renders it on top of the whole group (not above just the newest message).
|
||||
val olderMsg = ordered.getOrNull(i + 1)
|
||||
val dateKey = dayKey(msg.createdAt)
|
||||
if (dateKey != lastDateKey) {
|
||||
lastDateKey = dateKey
|
||||
if (olderMsg == null || dayKey(olderMsg.createdAt) != dateKey) {
|
||||
item(key = "date-$dateKey") {
|
||||
DateHeader(formatDateHeader(msg.createdAt))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user