Skip to content

Commit d6aebd9

Browse files
committed
Fix message info component to display read and delivered timestamps correctly
1 parent c586836 commit d6aebd9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/component/MessageInfoComponentFactory.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ private fun MessageInfoContent(
189189
items = reads,
190190
labelResId = R.string.message_info_read_by,
191191
skipTopPadding = true,
192+
getDate = ChannelUserRead::lastRead
192193
)
193194
// Delivered to section
194195
section(
195196
items = deliveredReads,
196197
labelResId = R.string.message_info_delivered_to,
198+
getDate = ChannelUserRead::lastDeliveredAt
197199
)
198200
}
199201
}
@@ -202,6 +204,7 @@ private fun LazyListScope.section(
202204
items: List<ChannelUserRead>,
203205
@StringRes labelResId: Int,
204206
skipTopPadding: Boolean = false,
207+
getDate: (ChannelUserRead) -> Date?,
205208
) {
206209
if (items.isNotEmpty()) {
207210
item {
@@ -226,7 +229,10 @@ private fun LazyListScope.section(
226229
index = index,
227230
lastIndex = items.lastIndex,
228231
) {
229-
ReadItem(userRead = item)
232+
ReadItem(
233+
userRead = item,
234+
getDate = getDate,
235+
)
230236
}
231237
}
232238
}
@@ -235,6 +241,7 @@ private fun LazyListScope.section(
235241
@Composable
236242
private fun ReadItem(
237243
userRead: ChannelUserRead,
244+
getDate: (ChannelUserRead) -> Date?,
238245
) {
239246
Row(
240247
horizontalArrangement = Arrangement.spacedBy(12.dp),
@@ -259,7 +266,7 @@ private fun ReadItem(
259266
)
260267

261268
Timestamp(
262-
date = userRead.lastDeliveredAt ?: userRead.lastRead,
269+
date = getDate(userRead),
263270
formatType = DateFormatType.RELATIVE,
264271
)
265272
}

0 commit comments

Comments
 (0)